pgsql: Fix nbtree cleanup-only VACUUM stats inaccuracies.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix nbtree cleanup-only VACUUM stats inaccuracies.
Date: 2020-11-05 02:43:30
Message-ID: E1kaVFK-0007jE-7d@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix nbtree cleanup-only VACUUM stats inaccuracies.

Logic for counting heap TIDs from posting list tuples (added by commit
0d861bbb) was faulty. It didn't count any TIDs/index tuples in the
event of no callback being set. This meant that we incorrectly counted
no index tuples in clean-up only VACUUMs, which could lead to
pg_class.reltuples being spuriously set to 0 in affected indexes.

To fix, go back to counting items from the page in cases where there is
no callback. This approach isn't very accurate, but it works well
enough in practice while avoiding the expense of accessing every index
tuple during cleanup-only VACUUMs.

Author: Peter Geoghegan <pg(at)bowt(dot)ie>
Reported-By: Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>
https://postgr.es/m/20201023174451.69e358f1@firost
Backpatch: 13-, where nbtree deduplication was introduced

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/48e1291342dd7771cf8c67aa1d7ec1f394b95dd8

Modified Files
--------------
src/backend/access/nbtree/nbtree.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2020-11-05 06:15:10 Re: pgsql: Add pg_depend.refobjversion.
Previous Message Thomas Munro 2020-11-05 01:18:08 pgsql: Fix unlinking of SLRU segments.