PostgreSQL Performance Tuning FAQ
Why should shared_buffers typically be set to 25% of system RAM in PostgreSQL?
PostgreSQL relies on both its internal shared buffer pool and the Linux OS page cache. Allocating 25% of RAM to shared_buffers while setting effective_cache_size to 75% prevents double-buffering overhead and leaves sufficient RAM for per-connection work_mem sorts and hash joins.
How can an aggressive work_mem value cause PostgreSQL OOM kills?
work_mem is allocated per sort or hash operation inside each query, not per connection. A single complex query running 4 hash joins across 200 concurrent connections can allocate up to 800x work_mem simultaneously. Always keep max_connections modest and place PgBouncer in front of high-concurrency workloads.
Why should random_page_cost be lowered from 4.0 to 1.1 on NVMe and cloud SSDs?
PostgreSQL defaults random_page_cost to 4.0 for legacy spinning hard drives. On modern NVMe and gp3/io2 cloud SSDs, random reads are nearly as fast as sequential reads, so lowering random_page_cost to 1.1 encourages the query planner to choose fast B-tree index scans instead of unnecessary sequential table scans.
Tuning Formulas & Official Pricing Sources (Verified Nov 2026)
- PostgreSQL Tuning Formulas: Based on PostgreSQL Official Resource Consumption Docs and standard Linux page-cache ratios (
shared_buffers = 25% RAM,effective_cache_size = 75% RAM,random_page_cost = 1.1for NVMe/SSD). - Cloud Hosting Reference Sources: AWS RDS for PostgreSQL Pricing, Supabase Pricing, Neon Serverless Postgres Pricing, and Hetzner Cloud VPS Pricing.