| I had a database table where I used UUID as primary key. Big mistake. Haunts us to this day. Not sortable. Takes a lot of space. Table relationships are annoying. Etc. What we do instead is have a secondary UUID key and keep Bigint as primary keys. Then use the UUID column in the external context instead. UUIDs are fine for 99.99999% of the time in your own domain. Don’t expect universal uniqueness across all domains. |
UUIDs are sortable, but don’t give you creation-order sorting (of course, its abusing bigint PKs to rely on them for that, too.) If you want creation-order sorting, storing a creation timestamp and sorting on that works, and I’ve never had a db that had a business requirement for creation order sorting and didn’t also have one for actual creation time.