Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit96f990e

Browse files
committed
Update some comments to clarify who does what in targetlist creation.
No code changes; just avoid blaming query_planner for things it doesn'treally do.
1 parent0527a45 commit96f990e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

‎src/backend/optimizer/plan/planner.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,17 +1248,17 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
12481248
need_sort_for_grouping= true;
12491249

12501250
/*
1251-
* Always overridequery_planner's tlist, so that we don't
1251+
* Always overridecreate_plan's tlist, so that we don't
12521252
* sort useless data from a "physical" tlist.
12531253
*/
12541254
need_tlist_eval= true;
12551255
}
12561256

12571257
/*
1258-
* create_plan() returns a plan with just a "flat" tlist of
1258+
* create_plan returns a plan with just a "flat" tlist of
12591259
* required Vars. Usually we need to insert the sub_tlist as the
12601260
* tlist of the top plan node.However, we can skip that if we
1261-
* determined that whateverquery_planner chose to return will be
1261+
* determined that whatevercreate_plan chose to return will be
12621262
* good enough.
12631263
*/
12641264
if (need_tlist_eval)
@@ -1311,7 +1311,7 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
13111311
else
13121312
{
13131313
/*
1314-
* Since we're usingquery_planner's tlist and not the one
1314+
* Since we're usingcreate_plan's tlist and not the one
13151315
* make_subplanTargetList calculated, we have to refigure any
13161316
* grouping-column indexes make_subplanTargetList computed.
13171317
*/
@@ -2521,10 +2521,11 @@ choose_hashed_distinct(PlannerInfo *root,
25212521
* make_subplanTargetList
25222522
* Generate appropriate target list when grouping is required.
25232523
*
2524-
* When grouping_planner inserts Aggregate, Group, or Result plan nodes
2525-
* above the result of query_planner, we typically want to pass a different
2526-
* target list to query_planner than the outer plan nodes should have.
2527-
* This routine generates the correct target list for the subplan.
2524+
* When grouping_planner inserts grouping or aggregation plan nodes
2525+
* above the scan/join plan constructed by query_planner+create_plan,
2526+
* we typically want the scan/join plan to emit a different target list
2527+
* than the outer plan nodes should have. This routine generates the
2528+
* correct target list for the scan/join subplan.
25282529
*
25292530
* The initial target list passed from the parser already contains entries
25302531
* for all ORDER BY and GROUP BY expressions, but it will not have entries
@@ -2547,15 +2548,18 @@ choose_hashed_distinct(PlannerInfo *root,
25472548
* If we are grouping or aggregating, *and* there are no non-Var grouping
25482549
* expressions, then the returned tlist is effectively dummy; we do not
25492550
* need to force it to be evaluated, because all the Vars it contains
2550-
* should be present in the output of query_planner anyway.
2551+
* should be present in the "flat" tlist generated by create_plan, though
2552+
* possibly in a different order. In that case we'll use create_plan's tlist,
2553+
* and the tlist made here is only needed as input to query_planner to tell
2554+
* it which Vars are needed in the output of the scan/join plan.
25512555
*
25522556
* 'tlist' is the query's target list.
25532557
* 'groupColIdx' receives an array of column numbers for the GROUP BY
2554-
*expressions (if there are any) in thesubplan's target list.
2558+
*expressions (if there are any) in thereturned target list.
25552559
* 'need_tlist_eval' is set true if we really need to evaluate the
2556-
*result tlist.
2560+
*returned tlist as-is.
25572561
*
2558-
* The result is the targetlist to be passed tothe subplan.
2562+
* The result is the targetlist to be passed toquery_planner.
25592563
*/
25602564
staticList*
25612565
make_subplanTargetList(PlannerInfo*root,
@@ -2649,7 +2653,7 @@ make_subplanTargetList(PlannerInfo *root,
26492653

26502654
/*
26512655
* locate_grouping_columns
2652-
*Locate grouping columns in the tlist chosen byquery_planner.
2656+
*Locate grouping columns in the tlist chosen bycreate_plan.
26532657
*
26542658
* This is only needed if we don't use the sub_tlist chosen by
26552659
* make_subplanTargetList.We have to forget the column indexes found

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp