pgsql: Scale VACUUM reltuples estimates after relation growth

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Scale VACUUM reltuples estimates after relation growth
Date: 2026-11-12 21:14:07
Message-ID: E1xRc7T-00000000TuH-1KdV@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)google(dot)com>
Author: Vaibhav Jain <jainva(at)google(dot)com>
Reviewed-by: Melanie Plageman <melanieplageman(at)gmail(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Dean Rasheed 2026-11-12 21:22:16 pgsql: Fix MERGE into inheritance parent with extra child columns.
Previous Message Melanie Plageman 2026-11-12 21:12:51 pgsql: Scale VACUUM reltuples estimates after relation growth