Random UUID keys triple Postgres WAL output per insert, study finds
A developer benchmarked three primary key types in PostgreSQL 16: bigint identity, random UUIDv4, and time-ordered UUIDv7. Each single-row insert with random UUIDs wrote about 558 bytes to the write-ahead log, versus 186 bytes for bigint, roughly tripling the log volume. The cause is that random keys scatter writes across the index, so many pages must be fully logged after each checkpoint to guard against torn writes. The author also found that random UUIDs produced larger indexes and less densely packed pages, while throughput on the test machine changed little. The UUIDv7 results were affected by a slower SQL-based generator and bulk-load conditions, which the author notes as caveats.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in