logoalt Hacker News

ULID: Universally Unique Lexicographically Sortable Identifier

62 pointsby der_gopher12/01/202552 commentsview on HN

Comments

rdtsclast Tuesday at 9:47 PM

> It is worth noting that the newest proposed standard for unique identifiers, UUID v7, aims to address the sortability and database performance issues of older UUID versions by adopting a similar time-ordered structure to ULID.

Yeah, I would go with UUID v7 at this point given that it's part of the UUID RFC https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-vers...

show 1 reply
sedatklast Tuesday at 10:26 PM

Whenever ULID comes up, I need to remind that it has a sequential ID generation mode in its spec which is prone to conflicts on multi-threads, processes or hosts which kills the purpose of a "universal" identifier. If you need a sequential ID, just use an integer, preferably one that's autoincremented by the database.

It's best to stick to UUIDv7 because of such quirks of ULID.

show 6 replies
nighthawk454last Tuesday at 9:15 PM

Mentioned in the article's comments:

> Why not use UUID7?

> "ULID is much older than UUID v7 though and looks nicer"

For those unfamiliar, UUIDv7 has pretty much the same properties – sortable, has timestamp, etc.

ULID: 01ARZ3NDEKTSV4RRFFQ69G5FAV

UUIDv7: 019b04ff-09e3-7abe-907f-d67ef9384f4f

show 3 replies
wafflestompyesterday at 5:35 AM

BTW, this doesn’t work well in S3 due to the timestamp being to the left of the randomness.

elias1233yesterday at 12:10 AM

I have always been a bit hesitant to use UUIDs with timestamps as it can be a security issue if the IDs are public. For example getting the age of a user account just from the id. I will say, however, that I have not heard of any major incidents stemming from this.

show 2 replies
sblomlast Tuesday at 9:24 PM

I love the aesthetics. The cryptographic strength tradeoffs (against UUIDv7) seem rough for a lot of applications, though.

show 1 reply
swyxyesterday at 3:04 AM

i keep a list of UUID info: https://github.com/swyxio/brain/blob/master/R%20-%20Dev%20No...

for those also learning

catlover7612/01/2025

[dead]

pklauslerlast Tuesday at 10:54 PM

Universally distinct would seem more correct than unique, at least mathematically speaking, unless there's only ever going to be just one of them.

N_Lensyesterday at 12:53 AM

Interesting article noting how ULIDs solve database index fragmentation caused when using UUIDv4. However, for extremely high-volume writes, ULIDs create "hot spots" at the current timestamp index location, potentially causing contention. The article notes that UUID v7 (newly standardized) adopts the same time-ordered approach, validating ULID's design.