| From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
|---|---|
| To: | Melanie Plageman <melanieplageman(at)gmail(dot)com> |
| Cc: | Vaibhav Jain <jainva(at)google(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, pg(at)bowt(dot)ie, andres(at)anarazel(dot)de |
| Subject: | Re: [BUG / PATCH] PG19: VACUUM misestimates reltuples (often 0) after on-access VM setting |
| Date: | 2026-11-13 00:59:59 |
| Message-ID: | CAHGQGwENjvnambqC_ZtXFLmMuYUbHzrtd6rg9pRUBUy_AuC7xw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, Nov 12, 2026 at 8:51 AM Melanie Plageman
<melanieplageman(at)gmail(dot)com> wrote:
> Attached is what I propose to backpatch to 19. It is basically the
> same as what you proposed but split up a bit differently.
> + if (old_rel_tuples < 0 || old_rel_pages == 0)
Should this use old_rel_tuples <= 0?
After DELETE followed by VACUUM (TRUNCATE false), an empty table can
have reltuples = 0 and relpages > 0. After repopulating it, on-access
pruning can mark most pages all-visible, and VACUUM can preserve the
old zero estimate even though the table contains rows.
For example:
---------------------------------
SET vacuum_max_eager_freeze_failure_rate = 0;
CREATE TABLE repro (v text) WITH (autovacuum_enabled = false);
INSERT INTO repro SELECT repeat('x', 300) FROM generate_series(1, 100000);
DELETE FROM repro;
VACUUM (TRUNCATE false) repro;
SELECT relpages, reltuples FROM pg_class WHERE oid = 'repro'::regclass;
INSERT INTO repro SELECT repeat('x', 300) FROM generate_series(1, 100000);
SELECT count(*) FROM repro;
VACUUM repro;
SELECT relpages, reltuples FROM pg_class WHERE oid = 'repro'::regclass;
---------------------------------
Regards,
--
Fujii Masao
| From | Date | Subject | |
|---|---|---|---|
| Next Message | surya poondla | 2026-11-13 01:02:06 | Re: two statement_timeout race conditions |
| Previous Message | Chao Li | 2026-11-13 00:17:50 | Re: [PATCH] doc: fix duplicate word typo in dependencyLockAndCheckObject comment |