Skip to content

Commit aadf7db

Browse files
committed
Mostly-cosmetic adjustments to estimate_multivariate_bucketsize().
The only practical effect of these changes is to avoid a useless list_copy() operation when there is a single hashclause. That's never going to make any noticeable performance difference, but the code is arguably clearer this way, especially if we take the opportunity to add some comments so that readers don't have to reverse-engineer the usage of these local variables. Also add some braces for better/more consistent style. Author: Tender Wang <tndrwang@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAHewXNnHBOO9NEa=NBDYOrwZL4oHu2NOcTYvqyNyWEswo8f5OQ@mail.gmail.com
1 parent cdf1f5a commit aadf7db

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/backend/utils/adt/selfuncs.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3798,18 +3798,25 @@ estimate_multivariate_bucketsize(PlannerInfo *root, RelOptInfo *inner,
37983798
List *hashclauses,
37993799
Selectivity *innerbucketsize)
38003800
{
3801-
List *clauses = list_copy(hashclauses);
3802-
List *otherclauses = NIL;
3803-
double ndistinct = 1.0;
3801+
List *clauses;
3802+
List *otherclauses;
3803+
double ndistinct;
38043804

38053805
if (list_length(hashclauses) <= 1)
3806-
3806+
{
38073807
/*
38083808
* Nothing to do for a single clause. Could we employ univariate
38093809
* extended stat here?
38103810
*/
38113811
return hashclauses;
3812+
}
38123813

3814+
/* "clauses" is the list of hashclauses we've not dealt with yet */
3815+
clauses = list_copy(hashclauses);
3816+
/* "otherclauses" holds clauses we are going to return to caller */
3817+
otherclauses = NIL;
3818+
/* current estimate of ndistinct */
3819+
ndistinct = 1.0;
38133820
while (clauses != NIL)
38143821
{
38153822
ListCell *lc;
@@ -3874,12 +3881,13 @@ estimate_multivariate_bucketsize(PlannerInfo *root, RelOptInfo *inner,
38743881
group_rel = root->simple_rel_array[relid];
38753882
}
38763883
else if (group_relid != relid)
3877-
3884+
{
38783885
/*
38793886
* Being in the group forming state we don't need other
38803887
* clauses.
38813888
*/
38823889
continue;
3890+
}
38833891

38843892
/*
38853893
* We're going to add the new clause to the varinfos list. We

0 commit comments

Comments
 (0)