A parallel sequential scan divides a table or partition into ranges and scans them concurrently. A leader process drives execution while parallel workers scan assigned data and return partial results. section 9.7
Inspecting a time-series query
Running EXPLAIN (ANALYZE, costs off) on an hourly walking-heart-rate query reveals a Parallel Seq Scan because the measurements table has no indexes. Workers scan alongside the leader; Gather Merge combines partial aggregates into the final fourteen-row result. section 9.7
Execution-plan clues include:
- Workers Planned and Workers Launched show parallel participation. section 9.7
- loops=2 on the scan indicates the leader and one worker scanned the partition. section 9.7
- An index-aware spatial predicate can avoid a parallel full-table scan; ST_Distance does not, while ST_DWithin uses the GiST index. section 10.6.2
EXPLAIN (analyze, costs off)
SELECT
time_bucket('1 hour', recorded_at) AS period,
AVG(heart_rate)::int AS avg_rate
FROM watch.heart_rate_measurements
WHERE activity = 'walking' AND watch_id = 1
AND recorded_at >= '2025-03-15 00:00'
AND recorded_at < '2025-03-16 00:00'
GROUP BY period ORDER BY period;
Use the executable EXPLAIN query to inspect the plan for the parallel scan. section 9.7
