Currently, I have a database with 13 millions rows and we use uuid
as the primary key. Everytime we do a database migration, it takes hours to finish a table. The query performance seems to be poor as well.
After Googling and reading some blogs, they recommended converting from uuid
to binary(16)
, but the converted value is unreadable and very awkward to use. It's also hard to use in my Ruby code.
Is there an alternative solution to get a globally unique identifer in MySQL beside uuid
?
mysql> select UNHEX(REPLACE('A4E7890F-A188-4663-89EB-176D94DF6774','-',''));
+---------------------------------------------------------------+
| UNHEX(REPLACE('A4E7890F-A188-4663-89EB-176D94DF6774','-','')) |
+---------------------------------------------------------------+
| ���Fc��m��gt |
I checked, and mongodb also has ObjectId
which is only 12 bytes. Is it possible to use that in MySQL server? How could I take advantage of that to use in MySQL?