On 9th of December, Robert Haas committed patch:

Allow EXPLAIN (ANALYZE, VERBOSE) to display per-worker statistics.
 
The original parallel sequential scan commit included only very limited
changes to the EXPLAIN output.  Aggregated totals from all workers were
displayed, but there was no way to see what each individual worker did
or to distinguish the effort made by the workers from the effort made by
the leader.
 
Per a gripe by Thom Brown (and maybe others).  Patch by me, reviewed
by Amit Kapila.

I wrote earlier about parallel seq scans in PostgreSQL.

Their explains weren't all that great, looked like:

$ explain analyze select * from test where some_text like '%xy%';
                                                      QUERY PLAN                                                       
-----------------------------------------------------------------------------------------------------------------------
 Gather  (cost=1000.00..7759.14 rows=100 width=59) (actual time=0.160..46.413 rows=6663 loops=1)
   Number of Workers: 3
   ->  Parallel Seq Scan on test  (cost=0.00..6749.14 rows=100 width=59) (actual time=0.034..44.427 rows=1666 loops=4)
         Filter: (some_text ~~ '%xy%'::text)
         Rows Removed by Filter: 248334
 Planning time: 0.046 ms
 Execution time: 47.489 ms
(7 rows)

but now, with this new patch, it contains more information:

$ explain (analyze, buffers, verbose) select * from test where some_text like '%xy%';
                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Gather  (cost=1000.00..7759.14 rows=100 width=59) (actual time=0.159..49.196 rows=6663 loops=1)
   Output: id, some_text
   Number of Workers: 3
   Buffers: shared hit=2713 read=8658
   ->  Parallel Seq Scan on public.test  (cost=0.00..6749.14 rows=100 width=59) (actual time=0.040..47.277 rows=1666 loops=4)
         Output: id, some_text
         Filter: (test.some_text ~~ '%xy%'::text)
         Rows Removed by Filter: 248334
         Buffers: shared hit=2464 read=8658
         Worker 0: actual time=0.021..47.322 rows=1662 loops=1
           Buffers: shared hit=616 read=2143
         Worker 1: actual time=0.062..47.464 rows=1590 loops=1
           Buffers: shared hit=616 read=1984
         Worker 2: actual time=0.021..47.458 rows=1611 loops=1
           Buffers: shared hit=591 read=2085
 Planning time: 0.047 ms
 Execution time: 50.258 ms
(17 rows)

I do miss “Rows Removed by Filter" for workers, but even as is, it gives you a lot of additional information that can used for further optimizations or debugging.

Now, if only Pg parallel executor could handle more things than plain seq scans … Anyway – it's really nice addition. Thanks a lot.

Leave a comment