Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/backend/optimizer/util/pathnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4483,9 +4483,12 @@ create_hashjoin_path(PlannerInfo *root,
/*
* For parallel hash, it is motionHazard. If there are parallel hash join on outside child,
* not use parallel hash.
* CBDB_PARALLEL_FIXME: At least, should not have impact on non-parallel path generation.
* CBDB_PARALLEL_FIXME:
* At least, should not have impact on non-parallel path generation and when there are no
* parallel-aware paths.
*/
if (enable_parallel && outer_path->barrierHazard && !parallel_hash)
if (enable_parallel && enable_parallel_hash &&
outer_path->barrierHazard && !parallel_hash)
return NULL;

if (parallel_hash && outer_path->barrierHazard)
Expand Down
33 changes: 33 additions & 0 deletions src/test/regress/expected/gp_parallel.out
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,39 @@ abort;
--
-- End of Test locus after eliding mtion node.
--
--
-- Test outer path has Motion of parallel plan.
--
begin;
create table t1(a int, b int) with(parallel_workers=3);
create table t2(b int, a int) with(parallel_workers=2);
insert into t1 select i, i+1 from generate_series(1, 10) i;
insert into t2 select i, i+1 from generate_series(1, 5) i;
analyze t1;
Comment thread
avamingli marked this conversation as resolved.
analyze t2;
set local optimizer=off;
set local enable_parallel=on;
set local enable_parallel_hash=off;
set local max_parallel_workers_per_gather= 4;
explain(costs off) select * from t1 right join t2 on t1.b = t2.a;
QUERY PLAN
------------------------------------------------------------------
Gather Motion 6:1 (slice1; segments: 6)
-> Hash Left Join
Hash Cond: (t2.a = t1.b)
-> Redistribute Motion 6:6 (slice2; segments: 6)
Hash Key: t2.a
Hash Module: 3
-> Parallel Seq Scan on t2
-> Hash
-> Redistribute Motion 3:6 (slice3; segments: 3)
Hash Key: t1.b
Hash Module: 3
-> Seq Scan on t1
Optimizer: Postgres query optimizer
(13 rows)

abort;
-- start_ignore
drop schema test_parallel cascade;
-- end_ignore
Expand Down
17 changes: 17 additions & 0 deletions src/test/regress/sql/gp_parallel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,23 @@ abort;
-- End of Test locus after eliding mtion node.
--

--
-- Test outer path has Motion of parallel plan.
--
begin;
create table t1(a int, b int) with(parallel_workers=3);
create table t2(b int, a int) with(parallel_workers=2);
insert into t1 select i, i+1 from generate_series(1, 10) i;
insert into t2 select i, i+1 from generate_series(1, 5) i;
analyze t1;
analyze t2;
set local optimizer=off;
set local enable_parallel=on;
set local enable_parallel_hash=off;
set local max_parallel_workers_per_gather= 4;
explain(costs off) select * from t1 right join t2 on t1.b = t2.a;
abort;

-- start_ignore
drop schema test_parallel cascade;
-- end_ignore
Expand Down