Hi hackers,
I'm sharing a small patch that removes an unused parameter (totalrows)
from compute_expr_stats function in extended_stats.c .
This function originally appeared in commit
a4d75c86bf15220df22de0a92c819ecef9db3849, which introduced extended
statistics on expressions. From what I can see, total rows is never used
in the current implementation, so this patch removes it
If there are reasons to keep this parameter, or if there's anything I
might have missed, I'd be happy to discuss further.
--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC.
From 0de17516bec761474761bf2862724b23ccb11beb Mon Sep 17 00:00:00 2001
From: Ilia Evdokimov <ilya.evdoki...@tantorlabs.ru>
Date: Thu, 26 Dec 2024 12:09:14 +0300
Subject: [PATCH v1] Remove unused totalrows parameter in compute_expr_stats
The totalrows parameter in compute_expr_stats is never referenced anyway
in the function or by its callers. It appears to have been introduced in
commit a4d75c86bf15220df22de0a92c819ecef9db3849, but it remained unused
---
src/backend/statistics/extended_stats.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index 99fdf208db..85da3edb10 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -89,9 +89,8 @@ typedef struct AnlExprData
VacAttrStats *vacattrstat; /* statistics attrs to analyze */
} AnlExprData;
-static void compute_expr_stats(Relation onerel, double totalrows,
- AnlExprData *exprdata, int nexprs,
- HeapTuple *rows, int numrows);
+static void compute_expr_stats(Relation onerel, AnlExprData *exprdata,
+ int nexprs, HeapTuple *rows, int numrows);
static Datum serialize_expr_stats(AnlExprData *exprdata, int nexprs);
static Datum expr_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull);
static AnlExprData *build_expr_data(List *exprs, int stattarget);
@@ -220,8 +219,7 @@ BuildRelationExtStatistics(Relation onerel, bool inh, double totalrows,
exprdata = build_expr_data(stat->exprs, stattarget);
nexprs = list_length(stat->exprs);
- compute_expr_stats(onerel, totalrows,
- exprdata, nexprs,
+ compute_expr_stats(onerel, exprdata, nexprs,
rows, numrows);
exprstats = serialize_expr_stats(exprdata, nexprs);
@@ -2107,9 +2105,8 @@ examine_opclause_args(List *args, Node **exprp, Const **cstp,
* Compute statistics about expressions of a relation.
*/
static void
-compute_expr_stats(Relation onerel, double totalrows,
- AnlExprData *exprdata, int nexprs,
- HeapTuple *rows, int numrows)
+compute_expr_stats(Relation onerel, AnlExprData *exprdata,
+ int nexprs, HeapTuple *rows, int numrows)
{
MemoryContext expr_context,
old_context;
--
2.34.1