pgsql: Fix VACUUM's reporting of dead-tuple counts to the stats collect

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix VACUUM's reporting of dead-tuple counts to the stats collect
Date: 2014-01-19 00:25:45
Message-ID: E1W4gCv-0002WN-PY@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix VACUUM's reporting of dead-tuple counts to the stats collector.

Historically, VACUUM has just reported its new_rel_tuples estimate
(the same thing it puts into pg_class.reltuples) to the stats collector.
That number counts both live and dead-but-not-yet-reclaimable tuples.
This behavior may once have been right, but modern versions of the
pgstats code track live and dead tuple counts separately, so putting
the total into n_live_tuples and zero into n_dead_tuples is surely
pretty bogus. Fix it to report live and dead tuple counts separately.

This doesn't really do much for situations where updating transactions
commit concurrently with a VACUUM scan (possibly causing double-counting or
omission of the tuples they add or delete); but it's clearly an improvement
over what we were doing before.

Hari Babu, reviewed by Amit Kapila

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/115f414124e71749d2d8f512e469ca63bc2166e5

Modified Files
--------------
src/backend/commands/vacuumlazy.c | 13 +++++++++++--
src/backend/postmaster/pgstat.c | 11 ++++++-----
src/include/pgstat.h | 5 +++--
3 files changed, 20 insertions(+), 9 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Stephen Frost 2014-01-19 02:05:23 pgsql: Add CREATE TABLESPACE ... WITH ... Options
Previous Message Stephen Frost 2014-01-19 00:11:20 pgsql: Add ALTER TABLESPACE ... MOVE command