From c41e2e9a9da7dc0161656a8815f802be6156d2cc Mon Sep 17 00:00:00 2001 From: Zhenghua Lyu Date: Mon, 26 Oct 2020 16:41:44 +0800 Subject: [PATCH] Consider the case when stanullfrac is 1.0 in get_variable_numdistinct. --- src/backend/utils/adt/selfuncs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index bec357fcef..ba4fda1630 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -5391,6 +5391,12 @@ get_variable_numdistinct(VariableStatData *vardata, bool *isdefault) if (ntuples < DEFAULT_NUM_DISTINCT) return clamp_row_est(ntuples); + /* + * The stats info shows that it is all NULL. + */ + if (stanullfrac == 1.0) + return 1.0; + *isdefault = true; return DEFAULT_NUM_DISTINCT; } -- 2.25.1