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

From: Shuntian Jiao <jiaoshuntian(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
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 15:15:25
Message-ID: CAJRV7SOfRNnLBxnn0v2mHft6yJ3QFRDJdSyphj8qTu=faVYsjw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Á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.

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?

> (Anyway I think it would make sense to keep this logic within
> vac_estimate_reltuples rather than having half it there and the
> other half out here in its caller, no? OTOH since that is an exported
> function and this is something that we will probably want to back-patch,
> it's worth preserving its ABI in stable branches.)

I agree about keeping the calculation in vac_estimate_reltuples() and
preserving its ABI if we back-patch.

Thanks,
Jiao Shuntian

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Narayanan Venkateswaran 2026-11-26 15:15:53 Re: BUG #19863: Adding a partition hides a row in a DEFAULT subpartition with reordered columns
Previous Message Dean Rasheed 2026-11-26 14:43:22 Re: BUG #19942: SIGSEGV crash (and wrong results) in MERGE ... RETURNING WITH (OLD/NEW) with VIRTUAL generated colum

Browse pgsql-hackers by date

  From Date Subject
Previous Message Jelte Fennema-Nio 2026-11-26 14:59:29 Re: postgres_fdw: Fix costing of remote sorts without remote estimates