logoalt Hacker News

the_mitsuhikoyesterday at 5:27 PM3 repliesview on HN

You're missing the point here. You can always go from ordered to randomness. You cannot go from randomness to ordered. So by intentionally removing the useful properties of UUIDv7, you're taking away some external API consumers' hypothetical possibility to leverage benefits. If I know (as an API consumer) that I have a database that for whatever reason prefers evenly distributed primary keys or something similar, I can always accomplish that by hashing. I just can never go the other way.


Replies

Lvl999Noobtoday at 5:22 AM

Never use someone else's synthetic key as your primary key. If you want ordered keys, even if the API is giving out sequential integers, you should still use your own sequential IDs.

avemgyesterday at 6:32 PM

I take your point, but I think your hypothetical is a wonderful example of Hyrum's Law. And for that reason, if I was going to go to the trouble of mapping my internal v7 uuids into something more random for public consumption, then I'd be sure generate something that doesn't look like a uuid at all so nobody gets any funny ideas about what they can do with it.

tart-lemonadeyesterday at 5:44 PM

Just to clarify, do you mean that UUIDv4 in general is worse, or just this 7->4 obfuscation?

show 1 reply