diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index d44a70b04e9..62388047528 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -5797,7 +5797,7 @@ Explainlocus(ExplainState *es, CdbLocusType locustype, int parallel) locus = "SegmentGeneralWorkers"; break; case CdbLocusType_OuterQuery: - locus = "OuteryQuery"; + locus = "OuterQuery"; break; case CdbLocusType_Replicated: locus = "Replicated"; diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 05131746da2..396fc318fca 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -627,7 +627,10 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags) } Assert(best_path->parallel_workers == best_path->locus.parallel_workers); - plan->locustype = best_path->locus.locustype; + if (plan->locustype == CdbLocusType_Null) + { + plan->locustype = best_path->locus.locustype; + } plan->parallel = best_path->locus.parallel_workers; return plan; @@ -2345,6 +2348,12 @@ inject_projection_plan(Plan *subplan, List *tlist, bool parallel_safe) copy_plan_costsize(plan, subplan); plan->parallel_safe = parallel_safe; + if (subplan != NULL) + { + plan->locustype = subplan->locustype; + plan->parallel = subplan->parallel; + } + return plan; } @@ -7282,6 +7291,9 @@ make_sort(Plan *lefttree, int numCols, node->collations = collations; node->nullsFirst = nullsFirst; + plan->locustype = lefttree->locustype; + plan->parallel = lefttree->parallel; + Assert(sortColIdx[0] != 0); node->noduplicates = false; /* CDB */ @@ -8016,6 +8028,8 @@ make_unique_from_sortclauses(Plan *lefttree, List *distinctList) plan->qual = NIL; plan->lefttree = lefttree; plan->righttree = NULL; + plan->locustype = lefttree->locustype; + plan->parallel = lefttree->parallel; /* * convert SortGroupClause list into arrays of attr indexes and equality diff --git a/src/test/regress/expected/offload_entry_to_qe.out b/src/test/regress/expected/offload_entry_to_qe.out index c6bd5f219db..1c1d0a13a25 100644 --- a/src/test/regress/expected/offload_entry_to_qe.out +++ b/src/test/regress/expected/offload_entry_to_qe.out @@ -364,14 +364,14 @@ explain (costs off, locus) select (select max((select distinct x from tst t2 whe Locus: Hashed SubPlan 1 -> Unique - Locus: OuteryQuery + Locus: OuterQuery -> Result - Locus: OuteryQuery + Locus: OuterQuery Filter: (t2.x = t1.x) -> Materialize - Locus: OuteryQuery + Locus: OuterQuery -> Broadcast Motion 3:3 (slice3; segments: 3) - Locus: OuteryQuery + Locus: OuterQuery -> Seq Scan on tst t2 Locus: Hashed SubPlan 2 diff --git a/src/test/regress/expected/subselect_gp.out b/src/test/regress/expected/subselect_gp.out index e56d7a2577d..7c7bedb7865 100644 --- a/src/test/regress/expected/subselect_gp.out +++ b/src/test/regress/expected/subselect_gp.out @@ -1840,26 +1840,36 @@ analyze dedup_reptab; -- tacked on, because even though all the rows are available in all the -- segments, you cannot distinguish join rows generated by the same "logical" -- row otherwise. -explain (costs off) +explain (costs off, locus) select * from dedup_reptab r where r.a in (select t.a/10 from dedup_tab t); QUERY PLAN --------------------------------------------------------------------------------------- Gather Motion 3:1 (slice1; segments: 3) + Locus: Entry -> Result + Locus: Hashed -> Unique + Locus: Hashed Group Key: (RowIdExpr) -> Sort + Locus: Hashed Sort Key (Distinct): (RowIdExpr) -> Redistribute Motion 3:3 (slice2; segments: 3) + Locus: Hashed Hash Key: (RowIdExpr) -> Hash Join + Locus: Hashed Hash Cond: ((t.a / 10) = r.a) -> Seq Scan on dedup_tab t + Locus: Hashed -> Hash + Locus: Replicated -> Broadcast Motion 1:3 (slice3; segments: 1) + Locus: Replicated -> Seq Scan on dedup_reptab r + Locus: SingleQE Optimizer: Postgres query optimizer -(15 rows) +(25 rows) select * from dedup_reptab r where r.a in (select t.a/10 from dedup_tab t); a diff --git a/src/test/regress/expected/subselect_gp_optimizer.out b/src/test/regress/expected/subselect_gp_optimizer.out index 36e39aeb6a7..ba31bb39a1d 100644 --- a/src/test/regress/expected/subselect_gp_optimizer.out +++ b/src/test/regress/expected/subselect_gp_optimizer.out @@ -1896,7 +1896,7 @@ analyze dedup_reptab; -- tacked on, because even though all the rows are available in all the -- segments, you cannot distinguish join rows generated by the same "logical" -- row otherwise. -explain (costs off) +explain (costs off, locus) select * from dedup_reptab r where r.a in (select t.a/10 from dedup_tab t); QUERY PLAN ------------------------------------------------------------------------ diff --git a/src/test/regress/sql/subselect_gp.sql b/src/test/regress/sql/subselect_gp.sql index 18c765cd8c5..8e36f03bf93 100644 --- a/src/test/regress/sql/subselect_gp.sql +++ b/src/test/regress/sql/subselect_gp.sql @@ -820,7 +820,7 @@ analyze dedup_reptab; -- tacked on, because even though all the rows are available in all the -- segments, you cannot distinguish join rows generated by the same "logical" -- row otherwise. -explain (costs off) +explain (costs off, locus) select * from dedup_reptab r where r.a in (select t.a/10 from dedup_tab t); select * from dedup_reptab r where r.a in (select t.a/10 from dedup_tab t);