Re: Why is INSERT-driven autovacuuming based on pg_class.reltuples?

2022-02-02 Thread Peter Geoghegan
On Tue, Feb 1, 2022 at 3:02 PM David Rowley wrote: > If we wanted a more current estimate for the number of tuples in a > relation then we could use reltuples / relpages * > RelationGetNumberOfBlocks(r). However, I still don't see why an > INSERT driven auto-vacuums are a particularly special

Re: Why is INSERT-driven autovacuuming based on pg_class.reltuples?

2022-02-01 Thread David Rowley
On Mon, 31 Jan 2022 at 17:28, David Rowley wrote: > If ANALYZE runs and sets pg_class.reltuples to 1 million, then we > insert 500k tuples, assuming a 0 vacuum_ins_threshold and a > vacuum_ins_scale_factor of 0.2, then we'll want to perform a vacuum as > "vac_ins_base_thresh +

Re: Why is INSERT-driven autovacuuming based on pg_class.reltuples?

2022-01-30 Thread David Rowley
On Fri, 28 Jan 2022 at 09:20, Peter Geoghegan wrote: > Both VACUUM and ANALYZE update pg_class.reltuples. But this code seems > to assume that it's only something that VACUUM can ever do. Like Justin I'm also not quite following what the problem is here. pg_class.reltuples is only used to

Re: Why is INSERT-driven autovacuuming based on pg_class.reltuples?

2022-01-30 Thread Justin Pryzby
On Thu, Jan 27, 2022 at 01:59:38PM -0800, Peter Geoghegan wrote: > On Thu, Jan 27, 2022 at 12:20 PM Peter Geoghegan wrote: > > Both VACUUM and ANALYZE update pg_class.reltuples. But this code seems > > to assume that it's only something that VACUUM can ever do. Why > > wouldn't we expect a plain

Re: Why is INSERT-driven autovacuuming based on pg_class.reltuples?

2022-01-28 Thread Peter Geoghegan
On Thu, Jan 27, 2022 at 11:22 PM Laurenz Albe wrote: > What would you suggest instead? pg_stat_all_tables.n_live_tup? I'm not sure, except that I assume that it'll have to come from the statistics collector, not from pg_class. I think that this bug stemmed from the fact that

Re: Why is INSERT-driven autovacuuming based on pg_class.reltuples?

2022-01-27 Thread Laurenz Albe
On Thu, 2022-01-27 at 12:20 -0800, Peter Geoghegan wrote: > I can see why the nearby, similar vacthresh and anlthresh variables > (not shown here) are scaled based on pg_class.reltuples -- that makes > sense. But why should we follow that example here, with vacinsthresh? What would you suggest

Re: Why is INSERT-driven autovacuuming based on pg_class.reltuples?

2022-01-27 Thread Peter Geoghegan
On Thu, Jan 27, 2022 at 12:20 PM Peter Geoghegan wrote: > Both VACUUM and ANALYZE update pg_class.reltuples. But this code seems > to assume that it's only something that VACUUM can ever do. Why > wouldn't we expect a plain ANALYZE to have actually been the last > thing to update

Why is INSERT-driven autovacuuming based on pg_class.reltuples?

2022-01-27 Thread Peter Geoghegan
Commit b07642dbcd ("Trigger autovacuum based on number of INSERTs") taught autovacuum to run in response to INSERTs, which is now typically the dominant factor that drives vacuuming for an append-only table -- a very useful feature, certainly. This is driven by the following logic from