Diagnosing Why Parallelism Was Disabled
Identify the functions, locks, and settings that silently force serial execution.
When the Plan Goes Serial
You expect a parallel sequential scan, but EXPLAIN shows a plain serial plan. Before blaming the planner's cost model, learn that PostgreSQL has many hard gates that silently veto parallelism entirely.
- Some are settings (max workers set to 0, low
parallel_setup_coststill too high). - Some are query shape (parallel-unsafe functions, write CTEs).
- Some are runtime (no free worker slots, or holding locks).
Our job in this lesson: systematically find which gate fired.
First Look: EXPLAIN ANALYZE
Start by confirming whether parallelism appeared at all. A parallel plan contains a Gather (or Gather Merge) node above the parallel-aware scan. If you only see plain Seq Scan, no workers were even considered viable.
The Workers Planned and Workers Launched lines tell you whether the planner wanted workers and whether it actually got them at runtime — two very different failures.
EXPLAIN (ANALYZE, VERBOSE, BUFFERS)
SELECT count(*)
FROM orders
WHERE amount > 100;
-- Look for:
-- Gather (cost=...)
-- Workers Planned: 2
-- Workers Launched: 2
-- -> Parallel Seq Scan on ordersAll lessons in this course
- When the Planner Chooses Parallel Plans
- Tuning Worker Counts and Gather Costs
- Parallel Aggregation and Hash Joins
- Diagnosing Why Parallelism Was Disabled