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

Commit648a6c7

Browse files
committed
Pass additional arguments to a couple of grouping-related functions.
get_number_of_groups() and make_partial_grouping_target() currentlyfish information directly out of the PlannerInfo; in the former case,the target list, and in the latter case, the HAVING qual. This worksfine if there's only one grouping relation, but if the pending patchfor partition-wise aggregate gets committed, we'll have multiplegrouping relations and must therefore use appropriately translatedversions of these values for each one. To make that simpler, pass thevalues to be used as arguments.Jeevan Chalke. The larger patch series of which this patch is a partwas also reviewed and tested by Antonin Houska, Rajkumar Raghuwanshi,David Rowley, Dilip Kumar, Konstantin Knizhnik, Pascal Legrand, RafiaSabih, and me.Discussion:http://postgr.es/m/CAM2+6=UqFnFUypOvLdm5TgC+2M=-E0Q7_LOh0VDFFzmk2BBPzQ@mail.gmail.comDiscussion:http://postgr.es/m/CAM2+6=W+L=C4yBqMrgrfTfNtbtmr4T53-hZhwbA2kvbZ9VMrrw@mail.gmail.com
1 parent8d1b805 commit648a6c7

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ static List *reorder_grouping_sets(List *groupingSets, List *sortclause);
130130
staticvoidstandard_qp_callback(PlannerInfo*root,void*extra);
131131
staticdoubleget_number_of_groups(PlannerInfo*root,
132132
doublepath_rows,
133-
grouping_sets_data*gd);
133+
grouping_sets_data*gd,
134+
List*target_list);
134135
staticSizeestimate_hashagg_tablesize(Path*path,
135136
constAggClauseCosts*agg_costs,
136137
doubledNumGroups);
@@ -175,7 +176,8 @@ static RelOptInfo *create_ordered_paths(PlannerInfo *root,
175176
staticPathTarget*make_group_input_target(PlannerInfo*root,
176177
PathTarget*final_target);
177178
staticPathTarget*make_partial_grouping_target(PlannerInfo*root,
178-
PathTarget*grouping_target);
179+
PathTarget*grouping_target,
180+
Node*havingQual);
179181
staticList*postprocess_setop_tlist(List*new_tlist,List*orig_tlist);
180182
staticList*select_active_windows(PlannerInfo*root,WindowFuncLists*wflists);
181183
staticPathTarget*make_window_input_target(PlannerInfo*root,
@@ -3505,6 +3507,7 @@ standard_qp_callback(PlannerInfo *root, void *extra)
35053507
*
35063508
* path_rows: number of output rows from scan/join step
35073509
* gd: grouping sets data including list of grouping sets and their clauses
3510+
* target_list: target list containing group clause references
35083511
*
35093512
* If doing grouping sets, we also annotate the gsets data with the estimates
35103513
* for each set and each individual rollup list, with a view to later
@@ -3513,7 +3516,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
35133516
staticdouble
35143517
get_number_of_groups(PlannerInfo*root,
35153518
doublepath_rows,
3516-
grouping_sets_data*gd)
3519+
grouping_sets_data*gd,
3520+
List*target_list)
35173521
{
35183522
Query*parse=root->parse;
35193523
doubledNumGroups;
@@ -3538,7 +3542,7 @@ get_number_of_groups(PlannerInfo *root,
35383542
ListCell*lc;
35393543

35403544
groupExprs=get_sortgrouplist_exprs(rollup->groupClause,
3541-
parse->targetList);
3545+
target_list);
35423546

35433547
rollup->numGroups=0.0;
35443548

@@ -3565,7 +3569,7 @@ get_number_of_groups(PlannerInfo *root,
35653569
gd->dNumHashGroups=0;
35663570

35673571
groupExprs=get_sortgrouplist_exprs(parse->groupClause,
3568-
parse->targetList);
3572+
target_list);
35693573

35703574
forboth(lc,gd->hash_sets_idx,lc2,gd->unsortable_sets)
35713575
{
@@ -3587,7 +3591,7 @@ get_number_of_groups(PlannerInfo *root,
35873591
{
35883592
/* Plain GROUP BY */
35893593
groupExprs=get_sortgrouplist_exprs(parse->groupClause,
3590-
parse->targetList);
3594+
target_list);
35913595

35923596
dNumGroups=estimate_num_groups(root,groupExprs,path_rows,
35933597
NULL);
@@ -3797,7 +3801,8 @@ create_grouping_paths(PlannerInfo *root,
37973801
*/
37983802
dNumGroups=get_number_of_groups(root,
37993803
cheapest_path->rows,
3800-
gd);
3804+
gd,
3805+
parse->targetList);
38013806

38023807
/*
38033808
* Determine whether it's possible to perform sort-based implementations
@@ -3859,7 +3864,8 @@ create_grouping_paths(PlannerInfo *root,
38593864
* appear in the result tlist, and (2) the Aggrefs must be set in
38603865
* partial mode.
38613866
*/
3862-
partial_grouping_target=make_partial_grouping_target(root,target);
3867+
partial_grouping_target=make_partial_grouping_target(root,target,
3868+
(Node*)parse->havingQual);
38633869
partially_grouped_rel->reltarget=partial_grouping_target;
38643870

38653871
/*
@@ -4912,10 +4918,12 @@ make_group_input_target(PlannerInfo *root, PathTarget *final_target)
49124918
* these would be Vars that are grouped by or used in grouping expressions.)
49134919
*
49144920
* grouping_target is the tlist to be emitted by the topmost aggregation step.
4915-
*We get the HAVING clause out of *root.
4921+
*havingQual represents the HAVING clause.
49164922
*/
49174923
staticPathTarget*
4918-
make_partial_grouping_target(PlannerInfo*root,PathTarget*grouping_target)
4924+
make_partial_grouping_target(PlannerInfo*root,
4925+
PathTarget*grouping_target,
4926+
Node*havingQual)
49194927
{
49204928
Query*parse=root->parse;
49214929
PathTarget*partial_target;
@@ -4957,8 +4965,8 @@ make_partial_grouping_target(PlannerInfo *root, PathTarget *grouping_target)
49574965
/*
49584966
* If there's a HAVING clause, we'll need the Vars/Aggrefs it uses, too.
49594967
*/
4960-
if (parse->havingQual)
4961-
non_group_cols=lappend(non_group_cols,parse->havingQual);
4968+
if (havingQual)
4969+
non_group_cols=lappend(non_group_cols,havingQual);
49624970

49634971
/*
49644972
* Pull out all the Vars, PlaceHolderVars, and Aggrefs mentioned in
@@ -6283,7 +6291,8 @@ add_paths_to_partial_grouping_rel(PlannerInfo *root,
62836291
/* Estimate number of partial groups. */
62846292
dNumPartialGroups=get_number_of_groups(root,
62856293
cheapest_partial_path->rows,
6286-
gd);
6294+
gd,
6295+
parse->targetList);
62876296

62886297
if (can_sort)
62896298
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp