Avoid extrapolating reltuples from tiny VACUUM samples Since b46e1e54d, on-access pruning can mark most pages all-visible before VACUUM or ANALYZE establishes tuple density. VACUUM may then scan only a tiny tail of mostly empty pages while reltuples is still unknown or reflects a previously empty table.
When no prior density is available, treat a sample of at most one page or less than two percent of the relation as insufficient and leave reltuples unknown instead of extrapolating. Reported-by: Vaibhav Jain <[email protected]> Author: Vaibhav Jain <[email protected]> Reviewed-by: Melanie Plageman <[email protected]> Discussion: https://postgr.es/m/flat/CABa-Az2YXuX%2B_JH8VL89i7oA%2BDC74GvfkSsM9%2B92fGCeWYVCqg%40mail.gmail.com Backpatch-through: 19 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/1a001d930ee8a105220b236035a975a166086870 Modified Files -------------- src/backend/access/heap/vacuumlazy.c | 5 ++--- src/backend/commands/vacuum.c | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-)
