| From: | Shuntian Jiao <jiaoshuntian(at)gmail(dot)com> |
|---|---|
| To: | Michael Banck <mbanck(at)gmx(dot)net> |
| Cc: | Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, pgsql-bugs(at)lists(dot)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773 |
| Date: | 2026-11-26 10:26:55 |
| Message-ID: | CAJRV7SOgKN9LCRZsLYYi5JU+14YRCHq=i8_aG=s3EiJwoSUN3Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-hackers |
Hi hackers,
I recently ran into this issue as well and reproduced it on master.
The table had 30,000 live rows, but after six autovacuum runs,
pg_class.reltuples had fallen to 1,831.
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. This version includes
no test case or other file changes. I can continue updating this patch
if needed.
The check uses counters VACUUM already collects, so it requires no
additional page reads. The trade-off is that if the previous estimate
was already too high after a real deletion, a partial vacuum meeting
these conditions can retain that overestimate.
I'd appreciate a review, particularly of whether these conditions are
a reasonable basis for keeping the previous estimate. I'm happy to
revise the patch based on feedback.
Thanks,
Jiao Shuntian
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-vacuum-reltuples.patch | application/octet-stream | 1.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Srinath Reddy Sadipiralla | 2026-11-26 11:33:03 | Re: BUG #19952: psql \d+ omits nondefault replica identity for partitioned tables |
| Previous Message | Raja Sai pranav | 2026-11-26 10:11:49 | btree_gist: <-> fails on same-sign infinite intervals |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Raja Sai pranav | 2026-11-26 10:31:53 | Re: Proposal: Conflict log history table for Logical Replication |
| Previous Message | Maksim.Melnikov | 2026-11-26 10:20:15 | Re: Infinite loop in XLogPageRead() on standby |