Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
PostgreSQL Enterprise & Performance 10+ Years (Principal / Architect) Expert Production Scenario

How do you tune `shared_buffers`, `work_mem`, and `maintenance_work_mem` for optimal PostgreSQL performance?

Real-World Scenario / Incident Description

Configuring a new 64-core, 256GB RAM database server for heavy OLTP workloads.

418 views • Updated 1 month ago

Optimal Memory Configuration

  • shared_buffers: Set to 25% of total RAM (64GB). PostgreSQL relies heavily on the Linux OS Page Cache for the remaining 75%.
  • work_mem: Allocated per-sort/hash operation per client (e.g. 32MB to 64MB). (Formula: (Available RAM / Max Connections) / 3).
  • maintenance_work_mem: Allocated for VACUUM and CREATE INDEX (e.g. 4GB).
  • effective_cache_size: Set to 75% of total RAM (192GB) to inform the optimizer of OS cache capacity.
Related Concepts: #PostgreSQL Tuning #Memory Configuration #DevOps