diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index c762ec61fbe..c12317b2a89 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -2299,7 +2299,6 @@ hash_inner_and_outer(PlannerInfo *root, save_jointype != JOIN_UNIQUE_OUTER && save_jointype != JOIN_FULL && save_jointype != JOIN_RIGHT && - save_jointype != JOIN_LASJ_NOTIN && save_jointype != JOIN_DEDUP_SEMI && save_jointype != JOIN_DEDUP_SEMI_REVERSE && outerrel->partial_pathlist != NIL && @@ -2319,6 +2318,7 @@ hash_inner_and_outer(PlannerInfo *root, */ if (innerrel->partial_pathlist != NIL && save_jointype != JOIN_UNIQUE_INNER && + save_jointype != JOIN_LASJ_NOTIN && enable_parallel_hash) { cheapest_partial_inner = diff --git a/src/test/regress/expected/gp_parallel.out b/src/test/regress/expected/gp_parallel.out index 21031b2accc..23bba396d3d 100644 --- a/src/test/regress/expected/gp_parallel.out +++ b/src/test/regress/expected/gp_parallel.out @@ -1590,6 +1590,81 @@ select * from t1 order by c2 asc limit 3 offset 5; abort; -- +-- Test Parallel Hash Left Anti Semi (Not-In) Join(parallel-oblivious). +-- +create table t1(c1 int, c2 int) using ao_row distributed by (c1); +create table t2(c1 int, c2 int) using ao_row distributed by (c1); +create table t3_null(c1 int, c2 int) using ao_row distributed by (c1); +set enable_parallel = on; +set gp_appendonly_insert_files = 2; +set gp_appendonly_insert_files_tuples_range = 100; +set max_parallel_workers_per_gather = 2; +insert into t1 select i, i from generate_series(1, 5000000) i; +insert into t2 select i+1, i from generate_series(1, 1200) i; +insert into t3_null select i+1, i from generate_series(1, 1200) i; +insert into t3_null values(NULL, NULL); +analyze t1; +analyze t2; +analyze t3_null; +explain(costs off) select sum(t1.c1) from t1 where c1 not in (select c1 from t2); + QUERY PLAN +--------------------------------------------------------------------------- + Finalize Aggregate + -> Gather Motion 6:1 (slice1; segments: 6) + -> Partial Aggregate + -> Hash Left Anti Semi (Not-In) Join + Hash Cond: (t1.c1 = t2.c1) + -> Parallel Seq Scan on t1 + -> Hash + -> Broadcast Motion 3:6 (slice2; segments: 3) + -> Seq Scan on t2 + Optimizer: Postgres query optimizer +(10 rows) + +select sum(t1.c1) from t1 where c1 not in (select c1 from t2); + sum +---------------- + 12500001778200 +(1 row) + +explain(costs off) select * from t1 where c1 not in (select c1 from t3_null); + QUERY PLAN +--------------------------------------------------------------- + Gather Motion 6:1 (slice1; segments: 6) + -> Hash Left Anti Semi (Not-In) Join + Hash Cond: (t1.c1 = t3_null.c1) + -> Parallel Seq Scan on t1 + -> Hash + -> Broadcast Motion 3:6 (slice2; segments: 3) + -> Seq Scan on t3_null + Optimizer: Postgres query optimizer +(8 rows) + +select * from t1 where c1 not in (select c1 from t3_null); + c1 | c2 +----+---- +(0 rows) + +-- non-parallel results. +set enable_parallel = off; +select sum(t1.c1) from t1 where c1 not in (select c1 from t2); + sum +---------------- + 12500001778200 +(1 row) + +select * from t1 where c1 not in (select c1 from t3_null); + c1 | c2 +----+---- +(0 rows) + +drop table t1; +drop table t2; +drop table t3_null; +-- +-- End of Test Parallel Hash Left Anti Semi (Not-In) Join. +-- +-- -- Test alter ao/aocs table parallel_workers options -- begin; diff --git a/src/test/regress/sql/gp_parallel.sql b/src/test/regress/sql/gp_parallel.sql index e6fd9657e86..6feaeaa4117 100644 --- a/src/test/regress/sql/gp_parallel.sql +++ b/src/test/regress/sql/gp_parallel.sql @@ -465,6 +465,39 @@ set local enable_parallel = off; explain(costs off, locus) select * from t1 order by c2 asc limit 3 offset 5; select * from t1 order by c2 asc limit 3 offset 5; abort; + +-- +-- Test Parallel Hash Left Anti Semi (Not-In) Join(parallel-oblivious). +-- +create table t1(c1 int, c2 int) using ao_row distributed by (c1); +create table t2(c1 int, c2 int) using ao_row distributed by (c1); +create table t3_null(c1 int, c2 int) using ao_row distributed by (c1); +set enable_parallel = on; +set gp_appendonly_insert_files = 2; +set gp_appendonly_insert_files_tuples_range = 100; +set max_parallel_workers_per_gather = 2; +insert into t1 select i, i from generate_series(1, 5000000) i; +insert into t2 select i+1, i from generate_series(1, 1200) i; +insert into t3_null select i+1, i from generate_series(1, 1200) i; +insert into t3_null values(NULL, NULL); +analyze t1; +analyze t2; +analyze t3_null; +explain(costs off) select sum(t1.c1) from t1 where c1 not in (select c1 from t2); +select sum(t1.c1) from t1 where c1 not in (select c1 from t2); +explain(costs off) select * from t1 where c1 not in (select c1 from t3_null); +select * from t1 where c1 not in (select c1 from t3_null); +-- non-parallel results. +set enable_parallel = off; +select sum(t1.c1) from t1 where c1 not in (select c1 from t2); +select * from t1 where c1 not in (select c1 from t3_null); +drop table t1; +drop table t2; +drop table t3_null; +-- +-- End of Test Parallel Hash Left Anti Semi (Not-In) Join. +-- + -- -- Test alter ao/aocs table parallel_workers options --