summaryrefslogtreecommitdiff
path: root/src/backend/statistics/extended_stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/statistics/extended_stats.c')
-rw-r--r--src/backend/statistics/extended_stats.c72
1 files changed, 39 insertions, 33 deletions
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index d1f818d49a8..c7e16f2f212 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -75,8 +75,8 @@ static VacAttrStats **lookup_var_attr_stats(Relation rel, Bitmapset *attrs,
static void statext_store(Oid relid,
MVNDistinct *ndistinct, MVDependencies *dependencies,
MCVList *mcv, VacAttrStats **stats);
-static int statext_compute_stattarget(int stattarget,
- int natts, VacAttrStats **stats);
+static int statext_compute_stattarget(int stattarget,
+ int natts, VacAttrStats **stats);
/*
* Compute requested extended stats, using the rows sampled for the plain
@@ -160,9 +160,9 @@ BuildRelationExtStatistics(Relation onerel, double totalrows,
stats);
/*
- * Don't rebuild statistics objects with statistics target set to 0 (we
- * just leave the existing values around, just like we do for regular
- * per-column statistics).
+ * Don't rebuild statistics objects with statistics target set to 0
+ * (we just leave the existing values around, just like we do for
+ * regular per-column statistics).
*/
if (stattarget == 0)
continue;
@@ -231,10 +231,10 @@ ComputeExtStatisticsRows(Relation onerel,
foreach(lc, lstats)
{
- StatExtEntry *stat = (StatExtEntry *) lfirst(lc);
- int stattarget = stat->stattarget;
- VacAttrStats **stats;
- int nattrs = bms_num_members(stat->columns);
+ StatExtEntry *stat = (StatExtEntry *) lfirst(lc);
+ int stattarget = stat->stattarget;
+ VacAttrStats **stats;
+ int nattrs = bms_num_members(stat->columns);
/*
* Check if we can build this statistics object based on the columns
@@ -291,19 +291,19 @@ ComputeExtStatisticsRows(Relation onerel,
static int
statext_compute_stattarget(int stattarget, int nattrs, VacAttrStats **stats)
{
- int i;
+ int i;
/*
- * If there's statistics target set for the statistics object, use it.
- * It may be set to 0 which disables building of that statistic.
+ * If there's statistics target set for the statistics object, use it. It
+ * may be set to 0 which disables building of that statistic.
*/
if (stattarget >= 0)
return stattarget;
/*
* The target for the statistics object is set to -1, in which case we
- * look at the maximum target set for any of the attributes the object
- * is defined on.
+ * look at the maximum target set for any of the attributes the object is
+ * defined on.
*/
for (i = 0; i < nattrs; i++)
{
@@ -1041,8 +1041,8 @@ statext_is_compatible_clause_internal(PlannerInfo *root, Node *clause,
/* Var IN Array */
if (IsA(clause, ScalarArrayOpExpr))
{
- RangeTblEntry *rte = root->simple_rte_array[relid];
- ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) clause;
+ RangeTblEntry *rte = root->simple_rte_array[relid];
+ ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) clause;
Var *var;
/* Only expressions with two arguments are considered compatible. */
@@ -1287,7 +1287,7 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli
ListCell *l;
Bitmapset **list_attnums;
int listidx;
- Selectivity sel = 1.0;
+ Selectivity sel = 1.0;
/* check if there's any stats that might be useful for us. */
if (!has_stats_of_kind(rel->statlist, STATS_EXT_MCV))
@@ -1338,7 +1338,10 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli
stat = choose_best_statistics(rel->statlist, STATS_EXT_MCV,
list_attnums, list_length(clauses));
- /* if no (additional) matching stats could be found then we've nothing to do */
+ /*
+ * if no (additional) matching stats could be found then we've nothing
+ * to do
+ */
if (!stat)
break;
@@ -1352,8 +1355,8 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli
foreach(l, clauses)
{
/*
- * If the clause is compatible with the selected statistics, mark it
- * as estimated and add it to the list to estimate.
+ * If the clause is compatible with the selected statistics, mark
+ * it as estimated and add it to the list to estimate.
*/
if (list_attnums[listidx] != NULL &&
bms_is_subset(list_attnums[listidx], stat->keys))
@@ -1371,15 +1374,15 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli
/*
* First compute "simple" selectivity, i.e. without the extended
* statistics, and essentially assuming independence of the
- * columns/clauses. We'll then use the various selectivities computed from
- * MCV list to improve it.
+ * columns/clauses. We'll then use the various selectivities computed
+ * from MCV list to improve it.
*/
simple_sel = clauselist_selectivity_simple(root, stat_clauses, varRelid,
- jointype, sjinfo, NULL);
+ jointype, sjinfo, NULL);
/*
- * Now compute the multi-column estimate from the MCV list, along with the
- * other selectivities (base & total selectivity).
+ * Now compute the multi-column estimate from the MCV list, along with
+ * the other selectivities (base & total selectivity).
*/
mcv_sel = mcv_clauselist_selectivity(root, stat, stat_clauses, varRelid,
jointype, sjinfo, rel,
@@ -1393,7 +1396,10 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli
if (other_sel > 1.0 - mcv_totalsel)
other_sel = 1.0 - mcv_totalsel;
- /* Overall selectivity is the combination of MCV and non-MCV estimates. */
+ /*
+ * Overall selectivity is the combination of MCV and non-MCV
+ * estimates.
+ */
stat_sel = mcv_sel + other_sel;
CLAMP_PROBABILITY(stat_sel);
@@ -1454,11 +1460,11 @@ statext_clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid,
bool
examine_clause_args(List *args, Var **varp, Const **cstp, bool *varonleftp)
{
- Var *var;
- Const *cst;
- bool varonleft;
- Node *leftop,
- *rightop;
+ Var *var;
+ Const *cst;
+ bool varonleft;
+ Node *leftop,
+ *rightop;
/* enforced by statext_is_compatible_clause_internal */
Assert(list_length(args) == 2);
@@ -1473,13 +1479,13 @@ examine_clause_args(List *args, Var **varp, Const **cstp, bool *varonleftp)
if (IsA(rightop, RelabelType))
rightop = (Node *) ((RelabelType *) rightop)->arg;
- if (IsA(leftop, Var) && IsA(rightop, Const))
+ if (IsA(leftop, Var) &&IsA(rightop, Const))
{
var = (Var *) leftop;
cst = (Const *) rightop;
varonleft = true;
}
- else if (IsA(leftop, Const) && IsA(rightop, Var))
+ else if (IsA(leftop, Const) &&IsA(rightop, Var))
{
var = (Var *) rightop;
cst = (Const *) leftop;