Why ULIDs Sort and Random UUIDs Don't
A ULID packs a 48-bit millisecond timestamp and 80 random bits into 26 Crockford Base32 characters. Because the timestamp comes first, plain string comparison sorts ULIDs chronologically - which is exactly what a B-tree index wants. Random UUID v4 keys land in random index positions and fragment the tree; time-ordered IDs simply append. The index benchmarks and byte-level structure are covered in UUID vs ULID.
The trade-off: anyone holding a ULID can decode when it was created - paste one into the decoder above to see for yourself. If you need time-ordering but your stack speaks UUID, UUID v7 gives you the same property in standard UUID clothing. For shorter, URL-safe IDs there is also Nanoid - the three formats are compared head-to-head in Nanoid vs UUID vs ULID.