From f370dbc5736923728068db94bdd4266888f76e13 Mon Sep 17 00:00:00 2001 From: Tender Wang Date: Mon, 14 Apr 2025 13:53:15 +0800 Subject: [PATCH] Adjust the place of list_copy() in estimate_multivariate_bucketsize. If we have a single hashclause, list_copy(hashclauses) is unnecessary. This adjustment can save the overhead of function calls and memory copies. --- src/backend/utils/adt/selfuncs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index a96b1b9c0bc6..cabc25c4a46c 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -3799,18 +3799,18 @@ estimate_multivariate_bucketsize(PlannerInfo *root, RelOptInfo *inner, List *hashclauses, Selectivity *innerbucketsize) { - List *clauses = list_copy(hashclauses); + List *clauses = NIL; List *otherclauses = NIL; double ndistinct = 1.0; + /* + * Nothing to do for a single clause. Could we employ univariate + * extended stat here? + */ if (list_length(hashclauses) <= 1) - - /* - * Nothing to do for a single clause. Could we employ univariate - * extended stat here? - */ return hashclauses; + clauses = list_copy(hashclauses); while (clauses != NIL) { ListCell *lc;