🌐 Machine-translated from Russian. Show original
In this part:
Why the default settings don't work
postgresql.conf by default is designed so that PostgreSQL runs on any computer, even on a Raspberry Pi: 128 MB for cache, careful disk settings. On a server with 32 GB of memory, this leaves most resources unused.
Procedure: first basic calculation using the formulas below, then measurements (part 5) and spot adjustment. Do not copy other people's configs from the internet entirely.
Memory: basic calculation
Example for a dedicated database server: 32 GB RAM, 8 cores, NVMe, up to 200 connections, mixed load (OLTP).
| Parameter | Rule | Example |
|---|---|---|
shared_buffers | ~25 % RAM | 8GB |
effective_cache_size | ~50–75% RAM (scheduler prompt, memory does not allocate) | 24GB |
work_mem | per sort/hash operation; (RAM − shared_buffers) / (max_connections × 2–4) | 32MB |
maintenance_work_mem | for VACUUM, CREATE INDEX; 1–2 GB on large | 1GB |
huge_pages | try by default; enable huge pages in the OS for shared_buffers from 8 GB | try |
