UUIDv4 vs UUIDv7

UUIDv4 generates identifiers from randomness. This spreads new values throughout an index, which can cause page splits and cache misses. In contrast, UUIDv7 is time-ordered: its high bits encode a timestamp, clustering inserts near the end of the index for better locality and natural sorting by creation time.

For analytics and event streams, v7 simplifies time-sorted operations. For privacy-sensitive contexts, v4 avoids leaking creation time. Collision risk is negligible for both when implemented correctly. Many systems can migrate by accepting both formats during a transition and backfilling existing records.

Related tools

Try: UUID generator, Random

FAQ

Why do many teams switch to UUIDv7?
UUIDv7 improves index locality and chronological ordering thanks to its timestamp prefix, reducing page splits and improving range scans in many databases.
Is UUIDv7 less private than v4?
UUIDv7 embeds a coarse timestamp, which may leak creation time. If that matters, consider v4 or apply additional privacy measures.