@@ -34,6 +34,49 @@ select count(*) from a_star;
3434 50
3535(1 row)
3636
37+ -- test with leader participation disabled
38+ set parallel_leader_participation = off;
39+ explain (costs off)
40+ select count(*) from tenk1 where stringu1 = 'GRAAAA';
41+ QUERY PLAN
42+ ---------------------------------------------------------
43+ Finalize Aggregate
44+ -> Gather
45+ Workers Planned: 4
46+ -> Partial Aggregate
47+ -> Parallel Seq Scan on tenk1
48+ Filter: (stringu1 = 'GRAAAA'::name)
49+ (6 rows)
50+
51+ select count(*) from tenk1 where stringu1 = 'GRAAAA';
52+ count
53+ -------
54+ 15
55+ (1 row)
56+
57+ -- test with leader participation disabled, but no workers available (so
58+ -- the leader will have to run the plan despite the setting)
59+ set max_parallel_workers = 0;
60+ explain (costs off)
61+ select count(*) from tenk1 where stringu1 = 'GRAAAA';
62+ QUERY PLAN
63+ ---------------------------------------------------------
64+ Finalize Aggregate
65+ -> Gather
66+ Workers Planned: 4
67+ -> Partial Aggregate
68+ -> Parallel Seq Scan on tenk1
69+ Filter: (stringu1 = 'GRAAAA'::name)
70+ (6 rows)
71+
72+ select count(*) from tenk1 where stringu1 = 'GRAAAA';
73+ count
74+ -------
75+ 15
76+ (1 row)
77+
78+ reset max_parallel_workers;
79+ reset parallel_leader_participation;
3780-- test that parallel_restricted function doesn't run in worker
3881alter table tenk1 set (parallel_workers = 4);
3982explain (verbose, costs off)
@@ -400,6 +443,49 @@ explain (costs off, verbose)
400443(11 rows)
401444
402445drop function simple_func(integer);
446+ -- test gather merge with parallel leader participation disabled
447+ set parallel_leader_participation = off;
448+ explain (costs off)
449+ select count(*) from tenk1 group by twenty;
450+ QUERY PLAN
451+ ----------------------------------------------------
452+ Finalize GroupAggregate
453+ Group Key: twenty
454+ -> Gather Merge
455+ Workers Planned: 4
456+ -> Partial GroupAggregate
457+ Group Key: twenty
458+ -> Sort
459+ Sort Key: twenty
460+ -> Parallel Seq Scan on tenk1
461+ (9 rows)
462+
463+ select count(*) from tenk1 group by twenty;
464+ count
465+ -------
466+ 500
467+ 500
468+ 500
469+ 500
470+ 500
471+ 500
472+ 500
473+ 500
474+ 500
475+ 500
476+ 500
477+ 500
478+ 500
479+ 500
480+ 500
481+ 500
482+ 500
483+ 500
484+ 500
485+ 500
486+ (20 rows)
487+
488+ reset parallel_leader_participation;
403489--test rescan behavior of gather merge
404490set enable_material = false;
405491explain (costs off)
@@ -508,6 +594,33 @@ select string4 from tenk1 order by string4 limit 5;
508594 AAAAxx
509595(5 rows)
510596
597+ -- gather merge test with 0 workers, with parallel leader
598+ -- participation disabled (the leader will have to run the plan
599+ -- despite the setting)
600+ set parallel_leader_participation = off;
601+ explain (costs off)
602+ select string4 from tenk1 order by string4 limit 5;
603+ QUERY PLAN
604+ ----------------------------------------------
605+ Limit
606+ -> Gather Merge
607+ Workers Planned: 4
608+ -> Sort
609+ Sort Key: string4
610+ -> Parallel Seq Scan on tenk1
611+ (6 rows)
612+
613+ select string4 from tenk1 order by string4 limit 5;
614+ string4
615+ ---------
616+ AAAAxx
617+ AAAAxx
618+ AAAAxx
619+ AAAAxx
620+ AAAAxx
621+ (5 rows)
622+
623+ reset parallel_leader_participation;
511624reset max_parallel_workers;
512625SAVEPOINT settings;
513626SET LOCAL force_parallel_mode = 1;
0 commit comments