ULID (Universally Unique Lexicographically Sortable Identifier) is a unique identifier designed to retain time-ordering information. A standard ULID contains 128 bits, including a 48-bit millisecond timestamp and 80 bits of randomness, and is normally represented as a 26-character string.
Because the timestamp is stored at the beginning of the identifier, ULIDs can generally be sorted lexicographically in the same order as their creation time.
A standard ULID contains a 48-bit millisecond timestamp followed by 80 bits of random data. It is encoded using Crockford Base32 and normally displayed as 26 characters.
Both ULID and UUID are designed for unique identification, but their design goals differ. Traditional UUIDs primarily focus on uniqueness, while ULID adds time-sortable characteristics.
The first 48 bits of a standard ULID store a millisecond Unix timestamp. This allows the identifier to carry time information that can be decoded for analysis and ordering.
Although ULIDs provide a very large identifier space, they should still be selected according to the requirements of the application. Database indexing, storage type, ordering behavior and the ID generation strategy should be considered together.
Comments 0