Why Modern Systems Use Time-Ordered Distributed IDs
Random UUIDv4 identifiers cause severe B-tree fragmentation in relational databases (like PostgreSQL and MySQL) because newly inserted rows are scattered randomly across disk pages, causing high I/O write amplification. Modern distributed architectures use time-ordered identifiers (UUIDv7, ULID, and Twitter Snowflake) where the leading 41 to 48 bits encode the current Unix epoch millisecond.
Key Differences: UUIDv7 vs Snowflake vs ULID
- UUIDv7 (RFC 9562): 128-bit standard UUID format with 48-bit millisecond timestamp + 74 bits of random entropy. Fully backward compatible with standard UUID columns.
- Twitter Snowflake: 64-bit integer format packing a 41-bit timestamp (custom epoch), 10-bit datacenter/worker ID, and 12-bit per-millisecond sequence counter. Compact and fits in standard BIGINT columns.
- ULID: 128-bit Crockford's Base32 string (26 characters). URL-safe, case-insensitive, and monotonically sortable.