aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/analyze.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 09d1b3db8fb..e7fcb558684 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -2732,7 +2732,21 @@ compute_scalar_stats(VacAttrStatsP stats,
slot_idx++;
}
}
- else if (nonnull_cnt == 0 && null_cnt > 0)
+ else if (nonnull_cnt > 0)
+ {
+ /* We found some non-null values, but they were all too wide */
+ Assert(nonnull_cnt == toowide_cnt);
+ stats->stats_valid = true;
+ /* Do the simple null-frac and width stats */
+ stats->stanullfrac = (double) null_cnt / (double) samplerows;
+ if (is_varwidth)
+ stats->stawidth = total_width / (double) nonnull_cnt;
+ else
+ stats->stawidth = stats->attrtype->typlen;
+ /* Assume all too-wide values are distinct, so it's a unique column */
+ stats->stadistinct = -1.0;
+ }
+ else if (null_cnt > 0)
{
/* We found only nulls; assume the column is entirely null */
stats->stats_valid = true;