max_parallel_workers_per_gather
Read PG 18 manual ↗Sets the maximum number of workers that can be started by a single Gather or Gather Merge node.
- Type
- integer
- Context
- user
- Measured default
- 2
- Unit
- —
- Metadata snapshot
- 18
Definition PG 18 manual
Sets the maximum number of workers that can be started by a single Gather or Gather Merge node. Parallel workers are taken from the pool of processes established by max_worker_processes, limited by max_parallel_workers. Note that the requested number of workers may not actually be available at run time. If this occurs, the plan will run with fewer workers than expected, which may be inefficient. The default value is 2. Setting this value to 0 disables parallel query execution.
Note that parallel queries may consume very substantially more resources than non-parallel queries, because each worker process is a completely separate process which has roughly the same impact on the system as an additional user session. This should be taken into account when choosing a value for this setting, as well as when configuring other settings that control resource utilization, such as work_mem. Resource limits such as work_mem are applied individually to each worker, which means the total utilization may be much higher across all processes than it would normally be for any single process. For example, a parallel query using 4 workers may use up to 5 times as much CPU time, memory, I/O bandwidth, and so forth as a query which uses no workers at all.
For more information on parallel query, see Chapter 15.
Measured default history
| Version interval | Default |
|---|---|
| 9.6 – 9.6 | 0 |
| 10 – 19 | 2 |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
max_parallel_workers_per_gather limits how many workers one Gather or Gather Merge node may request. Zero prevents parallel query execution through these nodes without disabling other background workers.
Workers are not reserved and can be unavailable at execution time because max_parallel_workers and max_worker_processes are shared pools. The leader process is not included in this numeric limit.
Each parallel plan can multiply work_mem-limited nodes, CPU demand, and I/O. The planner weighs parallel_setup_cost and parallel_tuple_cost before deciding whether to request workers. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.
Operational considerations
Treating max_parallel_workers_per_gather 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.
Workload guidance
OLAP: Analytical work can use a larger max_parallel_workers_per_gather, but multiply per-node memory and I/O by concurrent statements. Benchmark throughput under realistic worker contention rather than one isolated query.
OLTP: Set max_parallel_workers_per_gather 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.
SMALL: Keep max_parallel_workers_per_gather conservative on a small host. More possible workers can reduce throughput through context switching and memory pressure even when a single query becomes faster.
Version history 3
- PG 17 → 18changed
- PG 9.6 → 10changed
- PG 9.5 → 9.6added
Related entries
Further reading
Definition snapshot: english-manuals:860cfec16465c3fba79f368c245… · English manual source