diff --git a/src/backend/utils/adt/array_typanalyze.c b/src/backend/utils/adt/array_typanalyze.c new file mode 100644 index ffe8035..af31932 *** a/src/backend/utils/adt/array_typanalyze.c --- b/src/backend/utils/adt/array_typanalyze.c *************** compute_array_stats(VacAttrStats *stats, *** 448,457 **** int count_items_count; int i; TrackItem **sort_table; int track_len; int64 cutoff_freq; int64 minfreq, ! maxfreq; /* * We assume the standard stats code already took care of setting --- 448,459 ---- int count_items_count; int i; TrackItem **sort_table; + TrackItem *item_untracked = NULL; int track_len; int64 cutoff_freq; int64 minfreq, ! maxfreq, ! maxfreq_untracked=0; /* * We assume the standard stats code already took care of setting *************** compute_array_stats(VacAttrStats *stats, *** 467,472 **** --- 469,477 ---- * * Since epsilon = s/10 and bucket_width = 1/epsilon, the cutoff * frequency is 9*N / bucket_width. + * + * However, there is no histogram to fall back on when the MCE array + * is NULL, so force there to be at least one entry in the MCE array. */ cutoff_freq = 9 * element_no / bucket_width; *************** compute_array_stats(VacAttrStats *stats, *** 485,490 **** --- 490,505 ---- minfreq = Min(minfreq, item->frequency); maxfreq = Max(maxfreq, item->frequency); } + else if (item->frequency > maxfreq_untracked) + { + maxfreq_untracked = item->frequency; + item_untracked = item; + } + } + if (track_len==0 && item_untracked != NULL) + { + sort_table[track_len++] = item_untracked; + minfreq = maxfreq = maxfreq_untracked; } Assert(track_len <= i);