Dev Tools · 1h ago
Implementing UUID v7 by hand: time-sortable keys and the same-millisecond trap
UUID v7 uses a millisecond timestamp in the leading bits to make primary keys sortable by generation order, improving B-tree index performance. The author implements it in the browser using crypto.getRandomValues, avoiding Math.random(). A trap occurs when multiple UUIDs are generated in the same millisecond, requiring additional randomness to maintain uniqueness.
Meridian48 take
The article is a practical deep dive for developers, but the same-millisecond trap is well-known; the real value is the clear implementation guide.
Read the full reporting
Implementing UUID v7 by hand: time-sortable primary keys (and the same-millisecond trap) →
DEV Community
uuid-v7primary-keys