6 ms·
Simple sequential IDs are great. If you want UUID, v7 is the way to go since it maintains sequential ordering.
by bddicken 5mo ago
Simple sequential IDs are great. If you want UUID, v7 is the way to go since it maintains sequential ordering.
- jwpapi 5mo agoDoes all of that apply to Postgresql as well or only Mysql?
- sgarland 5mo agoBoth, assuming you’re ever going to index it - both use a form of a B+tree for their base indices. If it’s just being stored in the table, it doesn’t matter, but also if it doesn’t matter, just use v7.
- traderj0e 5mo agoI haven't explored hash indexes enough. That might be one thing that differs between Postgres and MySQL, because for a long time Postgres didn't have a good story for those.
- omcnoe 5mo agoThere are subtle gotchas around sequential UUID compared to serial depending on where you generate the UUIDs. You can kinda only get hard sequential guarantee if you are generating them at write time on DB host itself. But, for both Serial & db-gen’d sequential UUID you can still encounter transaction commit order surprises. I think software relying on sequential records should use some mechanism other than Id/PK to determine it. I’ve personally encountered extremely subtle bugs related to transaction commit order and sequential Id assumptions multiple times.