diff options
author | Richard Guo <rguo@postgresql.org> | 2024-07-23 11:18:53 +0900 |
---|---|---|
committer | Richard Guo <rguo@postgresql.org> | 2024-07-23 11:18:53 +0900 |
commit | 8b2e9fd26afd9f379ea8bedeb4b11a354c09a3e1 (patch) | |
tree | 8733dd6eb6cf0ad304b88fcd305658a5af4d1720 /src/backend/optimizer/plan/createplan.c | |
parent | 581df2148737fdb0ba6f2d8fda5ceb9d1e6302e6 (diff) | |
download | postgresql-8b2e9fd26afd9f379ea8bedeb4b11a354c09a3e1.tar.gz postgresql-8b2e9fd26afd9f379ea8bedeb4b11a354c09a3e1.zip |
Remove redundant code in create_gather_merge_path
In create_gather_merge_path, we should always guarantee that the
subpath is adequately ordered, and we do not add a Sort node in
createplan.c for a Gather Merge node. Therefore, the 'else' branch in
create_gather_merge_path, which computes the cost for a Sort node, is
redundant.
This patch removes the redundant code and emits an error if the
subpath is not sufficiently ordered. Meanwhile, this patch changes
the check for the subpath's pathkeys in create_gather_merge_plan to an
Assert.
Author: Richard Guo
Discussion: https://postgr.es/m/CAMbWs48u=0bWf3epVtULjJ-=M9Hbkz+ieZQAOS=BfbXZFqbDCg@mail.gmail.com
Diffstat (limited to 'src/backend/optimizer/plan/createplan.c')
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 6b64c4a362d..fe5a323cfd7 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -1987,16 +1987,11 @@ create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path) &gm_plan->collations, &gm_plan->nullsFirst); - /* * All gather merge paths should have already guaranteed the necessary - * sort order either by adding an explicit sort node or by using presorted - * input. We can't simply add a sort here on additional pathkeys, because - * we can't guarantee the sort would be safe. For example, expressions may - * be volatile or otherwise parallel unsafe. + * sort order. See create_gather_merge_path. */ - if (!pathkeys_contained_in(pathkeys, best_path->subpath->pathkeys)) - elog(ERROR, "gather merge input not sufficiently sorted"); + Assert(pathkeys_contained_in(pathkeys, best_path->subpath->pathkeys)); /* Now insert the subplan under GatherMerge. */ gm_plan->plan.lefttree = subplan; |