diff options
| author | Peter Geoghegan | 2021-03-11 00:27:01 +0000 |
|---|---|---|
| committer | Peter Geoghegan | 2021-03-11 00:27:01 +0000 |
| commit | 9f3665fbfc34b963933e51778c7feaa8134ac885 (patch) | |
| tree | f06201f72fc31718beb0b17f48facb270c28df26 /src/test | |
| parent | 845ac7f847a25505e91f30dca4e0330b25785ee0 (diff) | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/btree_index.out | 29 | ||||
| -rw-r--r-- | src/test/regress/sql/btree_index.sql | 19 |
2 files changed, 0 insertions, 48 deletions
diff --git a/src/test/regress/expected/btree_index.out b/src/test/regress/expected/btree_index.out index cfd4338e36..bc113a70b4 100644 --- a/src/test/regress/expected/btree_index.out +++ b/src/test/regress/expected/btree_index.out @@ -309,35 +309,6 @@ create index btree_tall_idx on btree_tall_tbl (t, id) with (fillfactor = 10); insert into btree_tall_tbl select g, repeat('x', 250) from generate_series(1, 130) g; -- --- Test vacuum_cleanup_index_scale_factor --- --- Simple create -create table btree_test(a int); -create index btree_idx1 on btree_test(a) with (vacuum_cleanup_index_scale_factor = 40.0); -select reloptions from pg_class WHERE oid = 'btree_idx1'::regclass; - reloptions ------------------------------------------- - {vacuum_cleanup_index_scale_factor=40.0} -(1 row) - --- Fail while setting improper values -create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = -10.0); -ERROR: value -10.0 out of bounds for option "vacuum_cleanup_index_scale_factor" -DETAIL: Valid values are between "0.000000" and "10000000000.000000". -create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = 100.0); -create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = 'string'); -ERROR: invalid value for floating point option "vacuum_cleanup_index_scale_factor": string -create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = true); -ERROR: invalid value for floating point option "vacuum_cleanup_index_scale_factor": true --- Simple ALTER INDEX -alter index btree_idx1 set (vacuum_cleanup_index_scale_factor = 70.0); -select reloptions from pg_class WHERE oid = 'btree_idx1'::regclass; - reloptions ------------------------------------------- - {vacuum_cleanup_index_scale_factor=70.0} -(1 row) - --- -- Test for multilevel page deletion -- CREATE TABLE delete_test_table (a bigint, b bigint, c bigint, d bigint); diff --git a/src/test/regress/sql/btree_index.sql b/src/test/regress/sql/btree_index.sql index 96f53818ff..c60312db2d 100644 --- a/src/test/regress/sql/btree_index.sql +++ b/src/test/regress/sql/btree_index.sql @@ -151,25 +151,6 @@ insert into btree_tall_tbl select g, repeat('x', 250) from generate_series(1, 130) g; -- --- Test vacuum_cleanup_index_scale_factor --- - --- Simple create -create table btree_test(a int); -create index btree_idx1 on btree_test(a) with (vacuum_cleanup_index_scale_factor = 40.0); -select reloptions from pg_class WHERE oid = 'btree_idx1'::regclass; - --- Fail while setting improper values -create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = -10.0); -create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = 100.0); -create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = 'string'); -create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = true); - --- Simple ALTER INDEX -alter index btree_idx1 set (vacuum_cleanup_index_scale_factor = 70.0); -select reloptions from pg_class WHERE oid = 'btree_idx1'::regclass; - --- -- Test for multilevel page deletion -- CREATE TABLE delete_test_table (a bigint, b bigint, c bigint, d bigint); |
