The idea · Lab 3.1.5Parallel query lets PostgreSQL split a large scan or aggregate across multiple background worker processes, each handling a slice of the table, with a Gather node combining their results back into one stream. It is a genuine capability, not a simulation — real worker processes launch and do real work. But it is not free: starting a worker, sending it a slice of work, and merging the results back all cost something, and the planner only chooses a parallel plan when its cost model expects that overhead to be worth paying. On a server with a single physical CPU, "worth paying" can come out negative — the workers still launch and still do real work, they just have to take turns on the one CPU that exists, and the coordination overhead is pure loss with no true concurrency underneath it.
JIT compilation is a different kind of question entirely: not whether it helps, but whether it can run at all. jit_provider defaults to llvmjit whether or not the underlying library is actually installed — a configured GUC value is not proof that the feature is functional, and the only way to know for certain is to check the filesystem directly.
Raising the Limit Alone Changes Nothing
SET max_parallel_workers_per_gather = 2;
EXPLAIN (ANALYZE, TIMING OFF) SELECT val, count(*) FROM big_a GROUP BY val;
The plan comes back identical to max_parallel_workers_per_gather = 0: a plain HashAggregate over a Seq Scan, no Gather node anywhere. Allowing more workers does not force the planner to use them — it still has to judge the parallel version worth the coordination overhead, using its normal cost model.
Forcing a Real Parallel Plan
SET parallel_setup_cost = 0;
SET parallel_tuple_cost = 0;
SET min_parallel_table_scan_size = 0;
EXPLAIN (ANALYZE, TIMING OFF) SELECT val, count(*) FROM big_a GROUP BY val;
HashAggregate (cost=680.33..1180.33 rows=50000 width=12) (actual rows=50000.00 loops=1)
-> Gather (cost=0.00..430.33 rows=50000 width=4) (actual rows=50000.00 loops=1)
Workers Planned: 2
Workers Launched: 2
-> Parallel Seq Scan on big_a (actual rows=16666.67 loops=3)
Execution Time: 1905.923 ms
With the overhead costs zeroed out to force the planner's hand, this is a genuine parallel plan — two real background workers launch (loops=3 counts the leader too), each scanning roughly a third of the table.
The Honest Measurement
| Plan | Execution Time |
|---|
| Serial (max_parallel_workers_per_gather=0) | 1171.199 ms |
| Forced parallel, 2 workers launched | 1905.923 ms |
Slower, not faster — on this single-vCPU VM, two worker processes and a leader are all sharing one physical core, so "parallel" here means taking turns with added coordination overhead, not simultaneous execution. This is exactly why the planner does not choose this plan on its own: its cost model is not being fooled, it is correctly avoiding overhead that would not pay off with the CPU resources actually available.
A Table Too Small to Bother With
SET max_parallel_workers_per_gather = 4;
EXPLAIN SELECT val, count(*) FROM small_agg GROUP BY val;
Even with four workers allowed, a 100-row table produces a plain serial plan — no Gather at all. parallel_tuple_cost and the other parallel cost GUCs correctly recognize that a table this small is not worth splitting up under any circumstances.
JIT: Configured Is Not the Same as Functional
SHOW jit_provider; -- llvmjit
SET jit = on;
SET jit_above_cost = 0; -- force JIT to be considered for even a cheap query
EXPLAIN (ANALYZE, TIMING OFF) SELECT count(*) FROM big_a;
No JIT: section appears anywhere in the output, no matter how aggressively the cost thresholds are lowered. find / -iname '*llvmjit*' confirms why: zero results. The shared library JIT compilation actually depends on is not present on this image — jit_provider = llvmjit is simply the compiled-in default value of a GUC, not evidence the feature can run.
Key concepts
Gather / Gather Merge
The plan node where a parallel query's worker processes hand their partial results back to the leader process to be combined into a single output stream. Gather Merge additionally preserves a sort order across workers; plain Gather does not guarantee any particular order. "Workers Planned" is what the planner intended; "Workers Launched" is how many the operating system actually started at execution time — the two can differ if background worker slots are unavailable.
JIT (Just-In-Time compilation)
PostgreSQL can compile expressions and tuple deforming code for a specific query into native machine code at execution time, via LLVM, instead of using the normal generic interpreted evaluation — worthwhile only for expensive, long-running queries, which is why it only activates above jit_above_cost by default. It requires the llvmjit shared library to actually be present and loadable; jit_provider naming "llvmjit" is only the configured default, not proof that library exists on a given install.
What to remember
- max_parallel_workers_per_gather raises a ceiling; it does not force the planner to use parallel workers unless its cost model judges it worthwhile
- A real parallel plan can be forced diagnostically by zeroing parallel_setup_cost and parallel_tuple_cost — a technique for seeing the alternative, not a permanent setting
- Parallel query genuinely launches real worker processes even on a single-vCPU machine, but with no true concurrent execution available, the coordination overhead can make it measurably slower than serial
- min_parallel_table_scan_size and parallel_tuple_cost correctly protect small tables from parallel overhead that would never be paid back
- A GUC naming a provider (jit_provider = llvmjit) configures a preference, not a guarantee that the underlying capability is installed — checking the filesystem directly settled the question here