Don't consider parallel append for parallel unsafe paths.
Commit ab72716778
allowed Parallel Append paths to be generated for a
relation that is not parallel safe. Prevent that from happening.
Initial analysis by Tom Lane.
Reported-by: Rajkumar Raghuwanshi
Author: Amit Kapila and Rajkumar Raghuwanshi
Reviewed-by: Amit Khandekar and Robert Haas
Discussion:https://postgr.es/m/CAKcux6=tPJ6nJ08r__nU_pmLQiC0xY15Fn0HvG1Cprsjdd9s_Q@mail.gmail.com
This commit is contained in:
parent
1c7c317cd9
commit
403318b71f
|
@ -1383,7 +1383,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
|
||||||
List *pa_partial_subpaths = NIL;
|
List *pa_partial_subpaths = NIL;
|
||||||
List *pa_nonpartial_subpaths = NIL;
|
List *pa_nonpartial_subpaths = NIL;
|
||||||
bool partial_subpaths_valid = true;
|
bool partial_subpaths_valid = true;
|
||||||
bool pa_subpaths_valid = enable_parallel_append;
|
bool pa_subpaths_valid;
|
||||||
List *all_child_pathkeys = NIL;
|
List *all_child_pathkeys = NIL;
|
||||||
List *all_child_outers = NIL;
|
List *all_child_outers = NIL;
|
||||||
ListCell *l;
|
ListCell *l;
|
||||||
|
@ -1391,6 +1391,9 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
|
||||||
bool build_partitioned_rels = false;
|
bool build_partitioned_rels = false;
|
||||||
double partial_rows = -1;
|
double partial_rows = -1;
|
||||||
|
|
||||||
|
/* If appropriate, consider parallel append */
|
||||||
|
pa_subpaths_valid = enable_parallel_append && rel->consider_parallel;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AppendPath generated for partitioned tables must record the RT indexes
|
* AppendPath generated for partitioned tables must record the RT indexes
|
||||||
* of partitioned tables that are direct or indirect children of this
|
* of partitioned tables that are direct or indirect children of this
|
||||||
|
|
|
@ -132,6 +132,32 @@ select sp_test_func() order by 1;
|
||||||
foo
|
foo
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
-- Parallel Append is not to be used when the subpath depends on the outer param
|
||||||
|
create table part_pa_test(a int, b int) partition by range(a);
|
||||||
|
create table part_pa_test_p1 partition of part_pa_test for values from (minvalue) to (0);
|
||||||
|
create table part_pa_test_p2 partition of part_pa_test for values from (0) to (maxvalue);
|
||||||
|
explain (costs off)
|
||||||
|
select (select max((select pa1.b from part_pa_test pa1 where pa1.a = pa2.a)))
|
||||||
|
from part_pa_test pa2;
|
||||||
|
QUERY PLAN
|
||||||
|
--------------------------------------------------------------
|
||||||
|
Aggregate
|
||||||
|
-> Gather
|
||||||
|
Workers Planned: 3
|
||||||
|
-> Parallel Append
|
||||||
|
-> Parallel Seq Scan on part_pa_test_p1 pa2
|
||||||
|
-> Parallel Seq Scan on part_pa_test_p2 pa2_1
|
||||||
|
SubPlan 2
|
||||||
|
-> Result
|
||||||
|
SubPlan 1
|
||||||
|
-> Append
|
||||||
|
-> Seq Scan on part_pa_test_p1 pa1
|
||||||
|
Filter: (a = pa2.a)
|
||||||
|
-> Seq Scan on part_pa_test_p2 pa1_1
|
||||||
|
Filter: (a = pa2.a)
|
||||||
|
(14 rows)
|
||||||
|
|
||||||
|
drop table part_pa_test;
|
||||||
-- test with leader participation disabled
|
-- test with leader participation disabled
|
||||||
set parallel_leader_participation = off;
|
set parallel_leader_participation = off;
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
|
|
|
@ -55,6 +55,15 @@ $$ select 'foo'::varchar union all select 'bar'::varchar $$
|
||||||
language sql stable;
|
language sql stable;
|
||||||
select sp_test_func() order by 1;
|
select sp_test_func() order by 1;
|
||||||
|
|
||||||
|
-- Parallel Append is not to be used when the subpath depends on the outer param
|
||||||
|
create table part_pa_test(a int, b int) partition by range(a);
|
||||||
|
create table part_pa_test_p1 partition of part_pa_test for values from (minvalue) to (0);
|
||||||
|
create table part_pa_test_p2 partition of part_pa_test for values from (0) to (maxvalue);
|
||||||
|
explain (costs off)
|
||||||
|
select (select max((select pa1.b from part_pa_test pa1 where pa1.a = pa2.a)))
|
||||||
|
from part_pa_test pa2;
|
||||||
|
drop table part_pa_test;
|
||||||
|
|
||||||
-- test with leader participation disabled
|
-- test with leader participation disabled
|
||||||
set parallel_leader_participation = off;
|
set parallel_leader_participation = off;
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
|
|
Loading…
Reference in New Issue