logoalt Hacker News

rcoder • yesterday at 10:16 PM • 1 reply • view on HN

If you really need monotonic, secure/unguessable IDs, there are options like CUID2 (github.com/paralleldrive/cuid2).

Older designs like ULIDs (https://github.com/ulid/spec) and Snowflake IDs (https://en.wikipedia.org/wiki/Snowflake_ID) have similar properties to UUIDv7, and potentially some advantages w.r.t. length/encoding/runtime cost/etc.

But UUIDv7 has one key advantage none of those do: you can store them in a UUID-typed column or struct field without any lossy conversion. All of the UUID versions share a common size and serialization format, so it doesn't actually matter if you generate v1/4/7/etc.

Many language standard libraries can generate them interchangeably, and (for example) a Postgres table can store any of the versions in the same column type.

So yes, to the author's point(s): they are not magic, monotonic, un-guessable IDs and you shouldn't treat them as either "secure" or strictly ordered. That doesn't mean they aren't useful.


Replies

hdjrudni • today at 2:06 AM

What is special about Postgres' column type? Is it not just binary(16)?