DevFormat
Language
Back to blog
February 25, 2026

UUID v4 vs. v7: Why Your Database Needs Time-Sortable IDs

Learn why the new UUID v7 standard is replacing v4 for database primary keys and how it improves indexing performance.

For years, UUID v4 was the industry standard for unique identifiers. But as databases grow, developers are discovering a fatal flaw: v4 is completely random, which destroys B-Tree indexing performance.

The Problem with UUID v4

Because v4 is random, new rows are inserted at random locations in your database index. This causes 'fragmentation' and forces the database to move data around constantly.

The Solution: UUID v7

UUID v7 is time-sortable. It includes a timestamp at the beginning, meaning new IDs always appear at the end of the index. This results in:

  1. Faster Inserts: No more index fragmentation.
  2. Better Locality: Related data stays close together.
  3. Native Support: It fits perfectly in existing 128-bit UUID columns.

👉 Generate Bulk UUID v7 for your Database here

Related Formatting Tool

Need to format your code right now? Use our secure tools.

Open JSON Formatter