| From: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
|---|---|
| To: | Erik Nordström <erik(at)timescale(dot)com>, Sami Imseih <samimseih(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Relstats after VACUUM FULL and CLUSTER |
| Date: | 2026-03-05 10:58:20 |
| Message-ID: | b21f07e6fb4cb35774f23023e4fc9f1de5bd970b.camel@cybertec.at |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, 2025-05-23 at 15:18 +0200, Erik Nordström wrote:
> I am wondering if the fix shouldn't be outside heap's copy_for_cluster implementation?
> I guess it depends on the semantics of num_tuples, but the cluster code seems to
> allude to interpreting num_tuples as the number of non-removable tuples.
> If you subtract recently dead from that number within the heap implementation,
> then it will no longer reflect non-removable tuples and the log message in the
> cluster function "found %.0f removable, %.0f nonremovable row versions" will no
> longer be correct.
>
> Surprisingly, tableam.h does not document the num_tuples parameter in the
> table_relation_copy_for_cluster() function although all other output parameters
> are documented. So, it is not clear what the intended semantics are. Maybe
> other hackers on the mailing list have opinions on how to interpret num_tuples?
I don't know how it was intended, but the lack of comments indicates to me that
perhaps nobody thought about it too hard, and your interpretation is fine.
> In any case, assuming num_tuples is supposed to return non-removable tuples,
> then the fix should be to subtract recently dead tuples when updating
> pg_class.reltuples. Other TAM's need to treat num_tuples as non-removable
> tuples as well, and update recently dead if applicable.
>
> I am attaching a patch with these changes, while also including the isolation
> test in that patch.
The patch applies fine and passes regression tests, and I see nothing wrong
with your approach.
There is one nit: "git am" complained about trailing whitespace in this line:
--- /dev/null
+++ b/src/test/isolation/specs/vacuum-full-stats.spec
[...]
+step s2_update { UPDATE stats SET a = 1 WHERE a > 6; }
Yours,
Laurenz Albe
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zhijie Hou (Fujitsu) | 2026-03-05 11:34:51 | RE: [PATCH] Support automatic sequence replication |
| Previous Message | Amit Kapila | 2026-03-05 10:46:50 | Re: [PATCH] Support automatic sequence replication |