Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > The other patch was ITAGAKI Takahiro's patch to fix n_dead_tuples in
> > pgstats after VACUUM when there is concurrent update activity.
>
> I objected (and still object) to this patch because it allows
> n_dead_tuples to drift arbitrarily far away from reality
> There was some discussion about better ways to do it, IIRC, but no new
> patch has been submitted.
I wrote the patch *after* the dicussion (and it is still valid with
some hunks). It sets n_dead_tuples as the follows:
| n_dead_tuples
---------------------------+---------------
(1) At the start of vacuum | N
(2) At the end of vacuum | M (>=N)
(3) After updating stats | M - N
So if we don't update the table during vacuum, n_dead_tuples will be
definitely zero. Even if there are some updates with inaccurate stats
in a vacuum, only the errors generated in the vacuum are left. Errors
generated before the vacuum are completely cleared so that the formula
does not enlarge the inaccuracy.
I've waited for the completion of "Recalculating OldestXmin in a
long-running vacuum" patch, because it changes the accuracy of (3).
But without the recalculating patch, I have no plan to modify my
n_dead_tuples patch any further.
Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center