ULID

acronym

programming

Stands for: Universally Unique Lexicographically Sortable Identifier

A sortable, unique identifier alternative to UUID.

Universally Unique Lexicographically Sortable Identifier encodes a timestamp plus randomness so IDs sort roughly by creation time while staying unique. It was a popular answer to UUIDv4's lack of ordering before UUIDv7 arrived.

A ULID is a unique identifier that sorts lexicographically by creation time, encoding a timestamp followed by randomness. It exists because UUID version 4 is entirely random, which makes it a poor database key.

The reason is index locality. Random keys insert at arbitrary points in a B-tree, fragmenting pages and dirtying many of them per batch of writes; time-ordered keys append, which keeps the working set small and the index compact. The trade is that a ULID leaks its creation time to anyone who sees it, and remains guessable in ordering, so it is right for internal keys and wrong for anything where an identifier should reveal nothing. UUID version 7 standardizes the same idea.

Also known as: ulid

All glossary entries