Avoid UUID Version 4 primary keys
3 points by knedl
3 points by knedl
The article doesn't mention ULID and I thought that might be relevant, not sure how that compares to UUIDv7 though. PS I didn't know they were a thing until I noticed this: https://lobste.rs/s/7fsqgl/ulid_only_identifier_you_should_use
You're still using 128 bits instead of 32 or 64, which means you fit less into a page, which means more IO.
I would have thought that the indexing problem the piece talks about would apply to any UUID format which involves hashing its inputs, which as I recall is most of them. It would have been nice to see that addressed in the piece. I would also have liked to see discussion of the privacy tradeoffs of the different UUID formats.
It seems like the real point here is that randomly distributed values have performance characteristics which may come as a surprise to some people. That's an important point, I'm just not sure how much of it is UUID-specific.
Most UUIDs don’t involve hashing (only 2 out of 7).
1 is time and MAC address
2 is a weird DCE thing
3 is MD5(namespace,name)
4 is random
5 is SHA1(namespace,name)
6 is 1 but big endian
7 is time and random
8 is for proprietary formats
RFC 9562’s security considerations briefly mentions the problems of MAC-based and time-based UUIDs.