Best way to handle large (UUID) as a MySQL table primary key

前端 未结 3 1891
后悔当初
后悔当初 2020-12-16 01:48

I have a UUID string that I want to use as my MySQL tables primary key, the UUID is a 32 character hexadecimal string (after \'-\' characters are stripped). Due to the fact

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-16 02:08

    For most cases it is best to store UUIDs/GUIDs as BINARY(16). See these related StackOverflow questions:

    • UUID Performance in MySQL
    • How to Store UUID as Number

    The conversion can (and probably should) be done in MySQL instead of PHP so whether you're using a 32bit PHP client or 64bits doesn't matter a bit (pun intended :P)

提交回复
热议问题