Re: Removing vacuum_cleanup_index_scale_factor
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-03-08T22:35:03Z
Lists: pgsql-hackers
Attachments
- 0001-VACUUM-ANALYZE-Always-set-pg_class.reltuples.patch (application/x-patch) patch 0001
- 0002-Remove-vacuum_cleanup_index_scale_factor-GUC-param.patch (application/x-patch) patch 0002
On Mon, Mar 8, 2021 at 1:38 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > As you say, the history here is a bit convoluted, but it seems like > a good principle to avoid interconnections between VACUUM and ANALYZE > as much as we can. I haven't been paying enough attention to this > thread to have more insight than that. The attached patch does what I proposed earlier today: it teaches do_analyze_rel() to always set pg_class.reltuples for indexes when it would do the same thing for the heap/table relation already. It's now uniform in that sense. Also included is a patch that removes the vacuum_cleanup_index_scale_factor mechanism for triggering an index scan during VACUUM -- that's what the second patch does (this depends on the first patch, really). Do you think that a backpatch to Postgres 13 for both of these patches would be acceptable? There are two main concerns that I have in mind here, both of which are only issues in Postgres 13: 1. Arguably the question of skipping scanning the index should have been considered by the autovacuum_vacuum_insert_scale_factor patch when it was committed for Postgres 13 -- but it wasn't. There is a regression that was tied to autovacuum_vacuum_insert_scale_factor in Postgres 13 by Mark Callaghan: https://smalldatum.blogspot.com/2021/01/insert-benchmark-postgres-is-still.html The blog post says: "Updates - To understand the small regression mentioned above for the l.i1 test (more CPU & write IO) I repeated the test with 100M rows using 2 configurations: one disabled index deduplication and the other disabled insert-triggered autovacuum. Disabling index deduplication had no effect and disabling insert-triggered autovacuum resolves the regression." I think that this regression is almost entirely explainable by the need to unnecessarily scan indexes for autovacuum VACUUMs that just need to set the visibility map. This issue is basically avoidable, just by removing the vacuum_cleanup_index_scale_factor cleanup-only VACUUM criteria (per my second patch). 2. I fixed a bug in nbtree deduplication btvacuumcleanup() stats in commit 48e12913. This fix still left things in kind of a bad state: there are still cases where the btvacuumcleanup()-only VACUUM case will set pg_class.reltuples to a value that is significantly below what it should be (it all depends on how effective deduplication is with the data). These remaining cases are effectively fixed by the second patch. I probably should have made btvacuumcleanup()-only VACUUMs set "stats->estimate_count = true" when I was working on the fix that became commit 48e12913. Purely because my approach was inherently approximate with posting list tuples, and so shouldn't be trusted for anything important (num_index_tuples is suitable for VACUUM VERBOSE output only in affected cases). I didn't set "stats->estimate_count = true" in affected cases because I was worried about unforeseen consequences. But this seems defensible now, all things considered. There are other things that are slightly broken but will be fixed by the first patch. But I'm really just worried about these two cases in Postgres 13. Thanks for weighing in -- Peter Geoghegan
Commits
-
VACUUM ANALYZE: Always update pg_class.reltuples.
- 5f8727f5a679 14.0 landed
- 1fc5a57386d1 13.3 landed
-
Don't consider newly inserted tuples in nbtree VACUUM.
- 9f3665fbfc34 14.0 landed
- 9663d124466f 13.3 landed
-
Fix nbtree cleanup-only VACUUM stats inaccuracies.
- 48e1291342dd 14.0 cited
-
Disable recheck_on_update optimization to avoid crashes.
- 5d28c9bd73e2 12.0 cited
-
Fix VACUUM so that it always updates pg_class.reltuples/relpages.
- b4b6923e03f4 9.1.0 cited
-
Clean up API for ambulkdelete/amvacuumcleanup as per today's discussion.
- e57345975cf8 8.2.0 cited
-
First steps towards statistics on expressional (nee functional) indexes.
- f0c9397f8085 8.0.0 cited