From 9663d124466f09696170631a2f2c0b40114166c8 Mon Sep 17 00:00:00 2001 From: Peter Geoghegan Date: Wed, 10 Mar 2021 16:26:58 -0800 Subject: 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 Reviewed-By: Masahiko Sawada Discussion: https://postgr.es/m/CAD21AoA4WHthN5uU6+WScZ7+J_RcEjmcuH94qcoUPuB42ShXzg@mail.gmail.com Backpatch: 13-, where autovacuum_vacuum_insert_threshold was added. --- doc/src/sgml/config.sgml | 41 -------------------------------------- doc/src/sgml/ref/create_index.sgml | 14 ------------- 2 files changed, 55 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index ca0d9bd917e..dd2778611f8 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -8349,47 +8349,6 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; - - vacuum_cleanup_index_scale_factor (floating point) - - vacuum_cleanup_index_scale_factor - configuration parameter - - - - - Specifies the fraction of the total number of heap tuples counted in - the previous statistics collection that can be inserted without - incurring an index scan at the VACUUM cleanup stage. - This setting currently applies to B-tree indexes only. - - - - If no tuples were deleted from the heap, B-tree indexes are still - scanned at the VACUUM cleanup stage when at least one - of the following conditions is met: the index statistics are stale, or - the index contains deleted pages that can be recycled during cleanup. - Index statistics are considered to be stale if the number of newly - inserted tuples exceeds the vacuum_cleanup_index_scale_factor - fraction of the total number of heap tuples detected by the previous - statistics collection. The total number of heap tuples is stored in - the index meta-page. Note that the meta-page does not include this data - until VACUUM finds no dead tuples, so B-tree index - scan at the cleanup stage can only be skipped if the second and - subsequent VACUUM cycles detect no dead tuples. - - - - The value can range from 0 to - 10000000000. - When vacuum_cleanup_index_scale_factor is set to - 0, index scans are never skipped during - VACUUM cleanup. The default value is 0.1. - - - - - bytea_output (enum) diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml index 3537dfaade6..5a1fd714783 100644 --- a/doc/src/sgml/ref/create_index.sgml +++ b/doc/src/sgml/ref/create_index.sgml @@ -434,20 +434,6 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] - - - vacuum_cleanup_index_scale_factor (floating point) - - vacuum_cleanup_index_scale_factor - storage parameter - - - - - Per-index value for . - - - -- cgit v1.2.3