My DB has ~100 tables and 3 for which I need UUIDs.
For these 3 tables, the main goal is simply to hide sensitive IDs to visitors.
MySQL 8 has introduced UUID support and I was planning for these 3 tables to use an UUID as a sequential PK doing:
UUID_TO_BIN(UUID(), true) -- Stored as BINARY(16)
My concerns are:
- No Last Inserted ID available anymore, I would have to select the UUID first
- No Auto-increment anymore (you can use a trigger instead, adding some complexity)
- Slight performance loss
For these reasons, I'm thinking about a hybrid solution:
- Using an INT with AI as the PK
- Adding a separate BINARY(16) column for the UUID, keeping it sequential and indexed (but not unique as unnecessary and resource consuming on inserts)
Am I missing something here? Hopefully MySQL will follow PostgreSQL and introduce a UUID() data type in the future to avoid these issues.