File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,7 @@ ExecReScanGatherMerge(GatherMergeState *node)
334334 ExecShutdownGatherMergeWorkers (node );
335335
336336 node -> initialized = false;
337+ node -> gm_initialized = false;
337338
338339 if (node -> pei )
339340 ExecParallelReinitialize (node -> pei );
Original file line number Diff line number Diff line change @@ -300,6 +300,49 @@ select count(*) from tenk1 group by twenty;
300300 500
301301(20 rows)
302302
303+ --test rescan behavior of gather merge
304+ set enable_material = false;
305+ explain (costs off)
306+ select * from
307+ (select string4, count(unique2)
308+ from tenk1 group by string4 order by string4) ss
309+ right join (values (1),(2),(3)) v(x) on true;
310+ QUERY PLAN
311+ ----------------------------------------------------------
312+ Nested Loop Left Join
313+ -> Values Scan on "*VALUES*"
314+ -> Finalize GroupAggregate
315+ Group Key: tenk1.string4
316+ -> Gather Merge
317+ Workers Planned: 4
318+ -> Partial GroupAggregate
319+ Group Key: tenk1.string4
320+ -> Sort
321+ Sort Key: tenk1.string4
322+ -> Parallel Seq Scan on tenk1
323+ (11 rows)
324+
325+ select * from
326+ (select string4, count(unique2)
327+ from tenk1 group by string4 order by string4) ss
328+ right join (values (1),(2),(3)) v(x) on true;
329+ string4 | count | x
330+ ---------+-------+---
331+ AAAAxx | 2500 | 1
332+ HHHHxx | 2500 | 1
333+ OOOOxx | 2500 | 1
334+ VVVVxx | 2500 | 1
335+ AAAAxx | 2500 | 2
336+ HHHHxx | 2500 | 2
337+ OOOOxx | 2500 | 2
338+ VVVVxx | 2500 | 2
339+ AAAAxx | 2500 | 3
340+ HHHHxx | 2500 | 3
341+ OOOOxx | 2500 | 3
342+ VVVVxx | 2500 | 3
343+ (12 rows)
344+
345+ reset enable_material;
303346-- gather merge test with 0 worker
304347set max_parallel_workers = 0;
305348explain (costs off)
Original file line number Diff line number Diff line change @@ -118,6 +118,22 @@ explain (costs off)
118118
119119select count (* ) from tenk1 group by twenty;
120120
121+ -- test rescan behavior of gather merge
122+ set enable_material = false;
123+
124+ explain (costs off)
125+ select * from
126+ (select string4, count (unique2)
127+ from tenk1 group by string4 order by string4) ss
128+ right join (values (1 ),(2 ),(3 )) v(x) on true;
129+
130+ select * from
131+ (select string4, count (unique2)
132+ from tenk1 group by string4 order by string4) ss
133+ right join (values (1 ),(2 ),(3 )) v(x) on true;
134+
135+ reset enable_material;
136+
121137-- gather merge test with 0 worker
122138set max_parallel_workers = 0 ;
123139explain (costs off)
You can’t perform that action at this time.
0 commit comments