I Load Tested 4 Postgres PK Types So You Don't Have To
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
A load test comparing four PostgreSQL primary key types — bigint identity, text, UUID v4, and UUID v7 — on select-by-primary-key performance at 1 million rows using K6. Across all concurrency levels (1 to 50 virtual users), all four types performed nearly identically, with differences of only 2–3%. The reason: all indexes fit within Postgres's 128 MB shared buffer cache, so every lookup was a memory read and disk I/O differences never materialized. The post explains when divergence would appear (tens of millions of rows, memory-constrained servers), and offers practical guidance: use int if you don't need globally unique IDs, prefer UUID v7 over v4 if you do, and consider insert performance separately since it tells a different story.