Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Shuntian Jiao <jiaoshuntian(at)gmail(dot)com>
Cc: Michael Banck <mbanck(at)gmx(dot)net>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773
Date: 2026-11-26 17:18:04
Message-ID: awhODEifwGhx5cPZ@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 2026-Nov-26, Shuntian Jiao wrote:

> Álvaro Herrera <alvherre(at)kurilemu(dot)de> 于2026年11月26日周四 20:45写道:
>
> > Hmm, but if the number of recently dead tuples is even one less
> > than the number of live tuples, the undesirable effect will
> > continue to occur AFAICS?
>
> You're right. After testing, I believe the threshold-based approach in
> v1 is not valid and is not a good solution.

So, the design that doesn't include recently-dead tuples comes from
commit 7c91a0364fcf; but I wonder if there were later changes elsewhere
in the code that affected the 'scanned_tuples' number we pass as input
for vac_estimate_reltuples. Maybe we should make scanned_tuples include
recently dead ones? (I fear that doing that might have the opposite
problem though, that is, that we would overestimate the number of live
tuples because of failing to subtract the recently-dead ones, so this
needs careful thought and lots of different little experiments.)

> One idea is to sample a few of the pages VACUUM would otherwise skip.
> We could use their average live-tuple density to estimate the rest of
> the skipped pages, then add the live tuples we actually counted. That
> would cost some extra heap reads. Does that seem worth trying, or is
> there a better way to estimate those pages with information VACUUM
> already has?

Doesn't sound great, since it requires more I/O, unjustified. The
number of people that requests to have VACUUM do more I/O is pretty low.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"El Maquinismo fue proscrito so pena de cosquilleo hasta la muerte"
(Ijon Tichy en Viajes, Stanislaw Lem)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message surya poondla 2026-11-26 17:35:38 Re: Parallel vacuum: check XID wraparound failsafe between indexes
Previous Message Álvaro Herrera 2026-11-26 17:04:09 [dave.sharpe@datastone.ca: [PATCH] doc: corrections for commands that are not MVCC-safe (REPACK CONCURRENTLY, pg_dump, REFRESH MATERIALIZED VIEW)]

Browse pgsql-bugs by date

  From Date Subject
Previous Message Diego 2026-11-26 16:18:43 Re: BUG #19688: pg_dump --schema scans all sequences in PostgreSQL 18, causing severe performance regression