postgresql/src/backend/access/rmgrdesc
Peter Geoghegan 9f3665fbfc Don't consider newly inserted tuples in nbtree VACUUM.
Remove the entire idea of "stale stats" within nbtree VACUUM (stop
caring about stats involving the number of inserted tuples).  Also
remove the vacuum_cleanup_index_scale_factor GUC/param on the master
branch (though just disable them on postgres 13).

The vacuum_cleanup_index_scale_factor/stats interface made the nbtree AM
partially responsible for deciding when pg_class.reltuples stats needed
to be updated.  This seems contrary to the spirit of the index AM API,
though -- it is not actually necessary for an index AM's bulk delete and
cleanup callbacks to provide accurate stats when it happens to be
inconvenient.  The core code owns that.  (Index AMs have the authority
to perform or not perform certain kinds of deferred cleanup based on
their own considerations, such as page deletion and recycling, but that
has little to do with pg_class.reltuples/num_index_tuples.)

This issue was fairly harmless until the introduction of the
autovacuum_vacuum_insert_threshold feature by commit b07642db, which had
an undesirable interaction with the vacuum_cleanup_index_scale_factor
mechanism: it made insert-driven autovacuums perform full index scans,
even though there is no real benefit to doing so.  This has been tied to
a regression with an append-only insert benchmark [1].

Also have remaining cases that perform a full scan of an index during a
cleanup-only nbtree VACUUM indicate that the final tuple count is only
an estimate.  This prevents vacuumlazy.c from setting the index's
pg_class.reltuples in those cases (it will now only update pg_class when
vacuumlazy.c had TIDs for nbtree to bulk delete).  This arguably fixes
an oversight in deduplication-related bugfix commit 48e12913.

[1] https://smalldatum.blogspot.com/2021/01/insert-benchmark-postgres-is-still.html

Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/CAD21AoA4WHthN5uU6+WScZ7+J_RcEjmcuH94qcoUPuB42ShXzg@mail.gmail.com
Backpatch: 13-, where autovacuum_vacuum_insert_threshold was added.
2021-03-10 16:27:01 -08:00
..
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
brindesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
clogdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
committsdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
dbasedesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
genericdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
gindesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
gistdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
hashdesc.c Standardize one aspect of rmgr desc output. 2021-01-04 19:46:11 -08:00
heapdesc.c Standardize one aspect of rmgr desc output. 2021-01-04 19:46:11 -08:00
logicalmsgdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
mxactdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
nbtdesc.c Don't consider newly inserted tuples in nbtree VACUUM. 2021-03-10 16:27:01 -08:00
relmapdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
replorigindesc.c Simplify printing of LSNs 2021-02-23 10:27:02 +01:00
seqdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
smgrdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
spgdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
standbydesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tblspcdesc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
xactdesc.c Simplify printing of LSNs 2021-02-23 10:27:02 +01:00
xlogdesc.c Simplify printing of LSNs 2021-02-23 10:27:02 +01:00