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:
- Faster Inserts: No more index fragmentation.
- Better Locality: Related data stays close together.
- Native Support: It fits perfectly in existing 128-bit UUID columns.