| 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 12:45:23 |
| Message-ID: | awgoVfTgjM6eWtrE@alvherre.pgsql |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-hackers |
On 2026-Nov-26, Shuntian Jiao wrote:
> I've attached a small patch that changes only vacuumlazy.c. When a
> partial vacuum finds more recently dead tuples than live ones, removes
> no tuples, and sees no change in the number of heap pages, it uses the
> previous reltuples estimate as a lower bound. With the patch, the
> estimate stayed at 30,000 across all six runs.
+ if (vacrel->scanned_pages < rel_pages &&
+ rel_pages == vacrel->rel->rd_rel->relpages &&
+ vacrel->tuples_deleted == 0 &&
+ vacrel->recently_dead_tuples > vacrel->live_tuples)
+ vacrel->new_live_tuples = Max(vacrel->new_live_tuples,
+ vacrel->rel->rd_rel->reltuples);
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?
(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.)
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"No hay hombre que no aspire a la plenitud, es decir,
la suma de experiencias de que un hombre es capaz"
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2026-11-26 12:56:28 | Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance |
| Previous Message | Álvaro Herrera | 2026-11-26 12:35:51 | Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773 |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-11-26 12:55:16 | Re: Parallel INSERT SELECT take 2 |
| Previous Message | Álvaro Herrera | 2026-11-26 12:35:51 | Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773 |