Autovacuum and visibility maps - Mailing list pgsql-general

From Tefft, Michael J
Subject Autovacuum and visibility maps
Date
Msg-id BN8PR04MB6289F7099F7B38E5B08D85B7D0362@BN8PR04MB6289.namprd04.prod.outlook.com
Whole thread Raw
Responses Re: Autovacuum and visibility maps
List pgsql-general

We have some batch queries that had occasionally having degraded runtimes: from 2 hours degrading to 16 hours, etc.

 

Comparing plans from good and bad runs, we saw that the good plans used index-only scans on table “x”, while the bad plans used index scans.

 

Using the pg_visibility utility, we found that all of the 83 partitions of table “x” were showing zero blocks where all tuples were visible. We ran a VACUUM on the table; the visibility maps are now clean and the good plans came back.

 

Our question is: why did autovacuum not spare us from this?

 

We are using default autovacuum parameters for all except log_autovacuum_min_duration=5000. These partitions are populated by processes that do a truncate + a single insert-select.

 

We see autovacuum failure (failed to get lock) messages, followed by a success message, in the log for one of these partitions (the biggest one) but even that partition showed zero blocks with all tuples visible.

 

Are we wrong to expect autovacuum to clean up the visibility map?

 

postgres=# select version();

                                                 version

----------------------------------------------------------------------------------------------------------

PostgreSQL 14.13 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22), 64-bit

 

Thank you,

Mike Tefft

pgsql-general by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: VACUUM FULL, power failure results in unrecoverable space
Next
From: Adrian Klaver
Date:
Subject: Re: Autovacuum and visibility maps