Why Postgres Cache Gets Pricier with Connections: Huge Pages Explained

arpit_bhayani · x · 2026-07-27

Arpit Bhayani explains why PostgreSQL's sharedbuffers cache becomes more expensive as connection counts rise. Because the OS manages memory in default 4 KB pages, each backend process maps the entire shared buffer segment, causing page table entries to scale linearly with connections.

The article notes that enabling Huge Pages (THP, e.g., 2 MB pages) mitigates this. Larger pages drastically reduce page table entries, allowing the TLB (Translation Lookaside Buffer) to cover almost the entire hot working set, bypassing page table lookups during reads. ClickHouse's managed Postgres even pins buffer caches to huge pages and refuses to boot if it fails, preventing silent fallbacks to 4 KB pages.

Related event: Why Postgres Shared Buffers Get Pricier with More Connections(2 posts)→

Original post →

More from Infra

Infra channel →