max_worker_processes
Fact — official short description: “Maximum number of concurrent worker processes.”
Identity
Lifecycle
| Fact | Value |
|---|---|
| First observed | PG9.4 |
| Present in | PG9.4–19 Beta 3 |
| Removed in | No |
| Introduction commit | 6bc8ef0b7f1f — Add new GUC, max_worker_processes, limiting number of bgworkers. |
| Commit date | 2013-07-04 |
| Discussion | — |
Default history
| Versions | Raw boot_val |
Unit | Human value |
|---|---|---|---|
| PG9.4–19 Beta 3 | 8 |
— | 8 |
How it works
max_worker_processes is the startup-time ceiling for concurrent background worker processes, including parallel workers and extension-managed workers. It is broader than max_parallel_workers.
The setting allocates shared control capacity but does not launch workers. Replication, extensions, logical apply, and parallel execution can all depend on slots beneath this ceiling.
A standby should normally configure the same or a higher value than its primary because worker requirements can be replayed or promoted. Increasing it without a CPU and memory budget only creates possible concurrency. 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 | Set max_worker_processes from a concurrency budget, not core count alone. Protect latency-sensitive OLTP from report and maintenance bursts, and verify actual Workers Planned versus Workers Launched. |
| OLAP | Analytical work can use a larger max_worker_processes, but multiply per-node memory and I/O by concurrent statements. Benchmark throughput under realistic worker contention rather than one isolated query. |
| Small nodes | Keep max_worker_processes conservative on a small host. More possible workers can reduce throughput through context switching and memory pressure even when a single query becomes faster. |
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 | 24 |
different | {{ pg_max_worker_processes + 8 }} |
| OLAP | 28 |
different | {{ pg_max_worker_processes + 8 }} |
| CRIT | 24 |
different | {{ pg_max_worker_processes + 8 }} |
| TINY | 20 |
different | {{ pg_max_worker_processes + 8 }} |
Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG9.4–19 Beta 3 = 24 (dcs); OLAP: PG9.4–19 Beta 3 = 28 (dcs); CRIT: PG9.4–19 Beta 3 = 24 (dcs); TINY: PG9.4–19 Beta 3 = 20 (dcs). Advice, pending human review — Editorial inference, pending maintainer review: The template expression adds worker headroom above its profile variable, likely reserving slots for extensions, replication, and parallel work; the exact capacity model needs maintainer confirmation.
Common pitfalls
- Treating max_worker_processes as reserved capacity rather than an upper bound shared with other work.
- Ignoring that parallel plans multiply CPU, I/O, and work_mem-limited nodes.
- Benchmarking one query without concurrent worker contention.
- Assuming planned workers will always be launched at execution time.
Related parameters
max_parallel_workers · max_parallel_workers_per_gather · max_parallel_maintenance_workers · max_logical_replication_workers · max_wal_senders