]> granicus.if.org Git - postgresql/commit
Fix compute_scalar_stats() for case that all values exceed WIDTH_THRESHOLD.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 11 Jan 2014 18:41:41 +0000 (13:41 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 11 Jan 2014 18:42:05 +0000 (13:42 -0500)
commit2d76d75d940759d6b734533ca61b8b59dc2acce1
tree45cd10d11ea7482bfe11eb0168d56052ae0a7de3
parenta29b6c34209a54e570338fcec343b11286005685
Fix compute_scalar_stats() for case that all values exceed WIDTH_THRESHOLD.

The standard typanalyze functions skip over values whose detoasted size
exceeds WIDTH_THRESHOLD (1024 bytes), so as to limit memory bloat during
ANALYZE.  However, we (I think I, actually :-() failed to consider the
possibility that *every* non-null value in a column is too wide.  While
compute_minimal_stats() seems to behave reasonably anyway in such a case,
compute_scalar_stats() just fell through and generated no pg_statistic
entry at all.  That's unnecessarily pessimistic: we can still produce
valid stanullfrac and stawidth values in such cases, since we do include
too-wide values in the average-width calculation.  Furthermore, since the
general assumption in this code is that too-wide values are probably all
distinct from each other, it seems reasonable to set stadistinct to -1
("all distinct").

Per complaint from Kadri Raudsepp.  This has been like this since roughly
neolithic times, so back-patch to all supported branches.
src/backend/commands/analyze.c