This is for every single row in your database and will increase the size of your database substantially.
This is for every single row in your database and will increase the size of your database substantially.
Use the native UUID data type, which only uses 16 bytes (UUIDs are basically just 128 bit integers). That is still double the size of a 64 bit integer, but the trade off is that it can be random and universally unique.
To clarify, UUID is stored in the db as 16 bytes (128 bits): https://en.wikipedia.org/wiki/Universally_unique_identifier#...
You would not store the 32 hex characters plus 4 hyphen characters as strings in the db. That UUID string format is for human readable display not disk storage.
(To downvoters, if 16 bytes is incorrect, please reply with what you believe to be the correct # of bytes for UUID.)
Try it for yourself.
As a side comment about MySQL, there are various techniques to store UUID more compactly as 16 bytes inside of a "binary(16)" type like this:
https://stackoverflow.com/a/28252188
... or similar technique shown at the bottom of the Percona blog:
https://www.percona.com/blog/2014/12/19/store-uuid-optimized...