|
|
|
|
|
by simonw
2950 days ago
|
|
The one time I used UUIDs as primary keys I quickly regretted it. They're huge, they're not possible to manually enter ("which row ID was causing that bug?") and they make foreign key relationships ugly and large too. If you want to generate IDs independently of the database you can do so using a "ID generator" mechanism. Set up three redis instances (or MySQL or anything else that can increment a counter). Have each one increment by three each time. Start then at 0, 1 and 2. Now you can ask any of those theee instances for a new ID and you'll get one that has not been used before, thanks to them being offset from each other. I first saw this technique used by Flickr when they switched to a Shaffer database. |
|