-
Notifications
You must be signed in to change notification settings - Fork 52
Description
I had some hosts where after adding both last_analyze and last_vacuum services I regularly had to do manual vacuuming, as some of our servers are so low traffic/churn that they do not hit the autovacuum water mark/parameter triggers.
After a while I discovered that for some servers and databases even a full
vacuumdb --all --analyze --freeze
did not seem to change the critical state from check_pgactivity. And while I am not an experienced perl writer, as far as I can guess why that is I think it's because of partitioned tables.
I checked first how check_pgactivity determined the state, and found a select from pg_stat_user_tables, using the fields last_vacuum, last_autovacuum, last_analyze and last_autoanalyze. I selected the object (schemaname, relname) and these fields, and found that for some tables these fields stay empty, even after the manual execution of vacuumdb.
Using
vacuumdb --all --analyze --freeze -e
I checked first which statement vacuumdb passed to PostgreSQL and found that for the tables that had a NULL value for the mentioned fields no vacuum statement was passed to PostgreSQL. I checked out these tables and found all of them to be partitioned tables.
My best guess at the moment would be that partitioned tables are not vacuumed, only its partitions.
To make sure that's not only a problem of the vacuumdb tool I tried to force a vacuum on such a partitioned table in psql:
vacuum (analyze, freeze) <tablename>
but that does not write any dates into the last_vacuum/last_autovacuum fields of the pg_stat_user_tables view for that table either.
PostgreSQL version: 15.14