Hi,
If planned parallel workers do not get launched, the Result Cache plan
node shows all-0 stats for each of those workers:
tpch=# set max_parallel_workers TO 0;
SET
tpch=# explain analyze
select avg(l_discount) from orders, lineitem
where
l_orderkey = o_orderkey
and o_orderdate < date '1995-03-09'
and l_shipdate > date '1995-03-09';
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------
Finalize Aggregate (cost=315012.87..315012.88 rows=1 width=32)
(actual time=27533.482..27533.598 rows=1 loops=1)
-> Gather (cost=315012.44..315012.85 rows=4 width=32) (actual
time=27533.471..27533.587 rows=1 loops=1)
Workers Planned: 4
Workers Launched: 0
-> Partial Aggregate (cost=314012.44..314012.45 rows=1
width=32) (actual time=27533.177..27533.178 rows=1 loops=1)
-> Nested Loop (cost=0.44..309046.68 rows=1986303
width=4) (actual time=0.400..27390.835 rows=748912 loops=1)
-> Parallel Seq Scan on lineitem
(cost=0.00..154513.66 rows=4120499 width=12) (actual
time=0.044..7910.399 rows=16243662 loops=1)
Filter: (l_shipdate > '1995-03-09'::date)
Rows Removed by Filter: 13756133
-> Result Cache (cost=0.44..0.53 rows=1
width=4) (actual time=0.001..0.001 rows=0 loops=16243662)
Cache Key: lineitem.l_orderkey
Hits: 12085749 Misses: 4157913 Evictions:
3256424 Overflows: 0 Memory Usage: 65537kB
Worker 0: Hits: 0 Misses: 0 Evictions: 0
Overflows: 0 Memory Usage: 0kB
Worker 1: Hits: 0 Misses: 0 Evictions: 0
Overflows: 0 Memory Usage: 0kB
Worker 2: Hits: 0 Misses: 0 Evictions: 0
Overflows: 0 Memory Usage: 0kB
Worker 3: Hits: 0 Misses: 0 Evictions: 0
Overflows: 0 Memory Usage: 0kB
-> Index Scan using orders_pkey on orders
(cost=0.43..0.52 rows=1 width=4) (actual time=0.002..0.002 rows=0
loops=4157913)
Index Cond: (o_orderkey = lineitem.l_orderkey)
Filter: (o_orderdate < '1995-03-09'::date)
Rows Removed by Filter: 1
Planning Time: 0.211 ms
Execution Time: 27553.477 ms
(22 rows)
By looking at the other cases like show_sort_info() or printing
per-worker jit info, I could see that the general policy is that we
skip printing info for workers that are not launched. Attached is a
patch to do the same for Result Cache.
I was earlier thinking about using (instrument[n].nloops == 0) to
check for not-launched workers. But we are already using "if
(rcstate->stats.cache_misses == 0)" for the leader process, so for
consistency I used the same method for workers.
--
Thanks,
-Amit Khandekar
Huawei Technologies