shared_buffers
Fact — official short description: “Sets the number of shared memory buffers used by the server.”
Identity
Lifecycle
| Fact | Value |
|---|---|
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |
Default history
| Versions | Raw boot_val |
Unit | Human value |
|---|---|---|---|
| PG9.0–14 | 1024 |
8kB |
8 MiB (1024 × 8kB) |
| PG15–19 Beta 3 | 16384 |
8kB |
128 MiB (16384 × 8kB) |
How it works
shared_buffers allocates PostgreSQL’s real shared buffer cache at server start. Pages cached here are PostgreSQL-managed and coexist with the operating system page cache; the setting is not merely a planner estimate.
The PG10-14 Docker boot value in this catalog is 8MB while PG15-18 report 128MB, reflecting historical initdb/container defaults rather than a universal hardware recommendation. The official guidance treats about 25% of RAM as a starting point for a dedicated server and rarely expects more than 40% to help.
A larger cache changes checkpoint and WAL pressure, often requiring a larger max_wal_size, and leaves less memory for backend processes, work_mem, maintenance, extensions, and the OS. Buffer allocation uses BLCKSZ units, normally 8kB. Its postmaster context fixes the value at server start; changing it requires a restart.
Tuning advice
Advice. These are workload-specific starting points and must be validated with measurements.
| Workload | Guidance |
|---|---|
| OLTP | Change shared_buffers only after identifying the corresponding resource bottleneck under concurrency. Budget total memory, I/O, disk, or kernel capacity rather than optimizing one process in isolation. |
| OLAP | Benchmark shared_buffers with representative bulk and scan phases. Include sustained throughput, spill/writeback, and interference with other sessions, not only one operation’s elapsed time. |
| Small nodes | Keep shared_buffers conservative on a small host and prefer the upstream default when evidence is weak. A setting copied from a large server can consume a disproportionate share of resources. |
Pigsty
Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.
| Template | Effective value | Versus upstream boot | Source expression |
|---|---|---|---|
| OLTP | 8192MB |
different | {{ pg_shared_buffers }}MB |
| OLAP | 8192MB |
different | {{ pg_shared_buffers }}MB |
| CRIT | 8192MB |
different | {{ pg_shared_buffers }}MB |
| TINY | 8192MB |
different | {{ pg_shared_buffers }}MB |
Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = 8192MB (dcs); OLAP: PG9.0–19 Beta 3 = 8192MB (dcs); CRIT: PG9.0–19 Beta 3 = 8192MB (dcs); TINY: PG9.0–19 Beta 3 = 8192MB (dcs). Advice, pending human review — Editorial inference, pending maintainer review: Pigsty deliberately parameterizes real shared-buffer allocation instead of hard-coding the fixture’s 8192MB; the published rationale must reference the host-memory sizing formula, not present 8192MB as a universal default.
Common pitfalls
- Changing shared_buffers without applying its documented unit and configuration context.
- Optimizing an isolated benchmark while ignoring concurrent aggregate resource use.
- Assuming a configured value guarantees operating-system or storage behavior.
- Failing to retest startup, failover, and workload latency after the change.
Related parameters
effective_cache_size · work_mem · max_wal_size · huge_pages · checkpoint_completion_target · wal_buffers