Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix explain(locus) issues. #433

Merged
merged 1 commit into from
May 16, 2024
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
2 changes: 1 addition & 1 deletion src/backend/commands/explain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
16 changes: 15 additions & 1 deletion src/backend/optimizer/plan/createplan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/test/regress/expected/offload_entry_to_qe.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions src/test/regress/expected/subselect_gp.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/regress/expected/subselect_gp_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/test/regress/sql/subselect_gp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading