DD
DevDash

UUID v4 vs v7 — Which Should You Use?

Quick Answer: UUID v4 is fully random and universally supported. UUID v7 is time-sorted, giving 2-10x better database insert performance due to sequential index writes. Use v7 for new projects with database primary keys; use v4 when you need zero timestamp leakage.

FAQ

Why is UUID v7 faster for databases?

Random v4 UUIDs cause B-tree index page splits on every insert. Time-sorted v7 UUIDs append to the end of the index, reducing I/O by 2-10x.

Does UUID v7 leak creation time?

Yes. The first 48 bits encode a millisecond Unix timestamp. If creation time is sensitive, use UUID v4 instead.

Is UUID v7 widely supported?

UUID v7 is part of RFC 9562 (2024). Libraries exist for all major languages. PostgreSQL 17+ and most ORMs support it natively.

Want API access + no ads? Pro coming soon.