PostgreSQL Memory Tuning Guide
Why Memory Tuning Matters
PostgreSQL performance heavily depends on memory configuration. Poor memory settings can cause slow queries and disk-based operations.
shared_buffers
This setting determines how much memory PostgreSQL uses for caching data pages.
shared_buffers = 25% of system RAM
work_mem
Used for sorting and hashing operations. Too low causes disk spill; too high can exhaust memory under concurrency.
work_mem = 4MB–64MB (depending on workload)
effective_cache_size
Helps the planner estimate available OS cache. Usually set to 50–75% of RAM.