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: Scale VACUUM reltuples estimates after relation growth
Date: Thu, 12 Nov 2026 21:14:07 +0000
Message-ID: <E1xRc7T-00000000TuH-1KdV@gemulon.postgresql.org> (raw)

Scale VACUUM reltuples estimates after relation growth

VACUUM kept the old reltuples value when it scanned at most one page,
even if the relation size changed. This left stale estimates after table
growth or shrinkage. Commit b46e1e54d made scanning one page more likely
by allowing newly populated pages to become all-visible before VACUUM.

Preserve reltuples only when relation size is unchanged; otherwise, scale
the old tuple density to the current size.

Only backpatch as far as 19, even though it was present before, to avoid
changing stats logic in stable branches.

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/baa86d46a186d56d2377e2946ac7ce6e8ed1e0be

Modified Files
--------------
src/backend/commands/vacuum.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)



view thread (2+ messages)

Message-ID: <E1xRc7T-00000000TuH-1KdV@gemulon.postgresql.org>
Permalink:  ../E1xRc7T-00000000TuH-1KdV@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xRc7T-00000000TuH-1KdV@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: Scale VACUUM reltuples estimates after relation growth
  In-Reply-To: <E1xRc7T-00000000TuH-1KdV@gemulon.postgresql.org>
  References: <E1xRc7T-00000000TuH-1KdV@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