pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Melanie Plageman <melanieplageman@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid extrapolating reltuples from tiny VACUUM samples
Date: Thu, 12 Nov 2026 21:07:10 +0000
Message-ID: <E1xRc0k-00000000TpM-38ac@gemulon.postgresql.org> (raw)

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 <jainva@google.com>
Author: Vaibhav Jain <jainva@google.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/flat/CABa-Az2YXuX%2B_JH8VL89i7oA%2BDC74GvfkSsM9%2B92fGCeWYVCqg%40mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ab79429c26d3980535457cc618c79328a9ebf495

Modified Files
--------------
src/backend/access/heap/vacuumlazy.c |  5 ++---
src/backend/commands/vacuum.c        | 21 ++++++++++++++-------
2 files changed, 16 insertions(+), 10 deletions(-)



view thread (2+ messages)

Message-ID: <E1xRc0k-00000000TpM-38ac@gemulon.postgresql.org>
Permalink:  ../E1xRc0k-00000000TpM-38ac@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xRc0k-00000000TpM-38ac@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: melanieplageman@gmail.com
  Subject: Re: pgsql: Avoid extrapolating reltuples from tiny VACUUM samples
  In-Reply-To: <E1xRc0k-00000000TpM-38ac@gemulon.postgresql.org>
  References: <E1xRc0k-00000000TpM-38ac@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox