52.30. pg_stats_vacuum_database#

The view pg_stats_vacuum_database will contain one row for each database in the current cluster, showing statistics about vacuuming that database.

Table 52.30. pg_stats_vacuum_database Columns

Column Type

Description

dboidoid

OID of a database

db_blks_readint8

Number of database blocks read by vacuum operations performed on this database

db_blks_hitint8

Number of times database blocks were found in the buffer cache by vacuum operations performed on this database

total_blks_dirtiedint8

Number of database blocks dirtied by vacuum operations performed on this database

total_blks_writtenint8

Number of database blocks written by vacuum operations performed on this database

wal_recordsint8

Total number of WAL records generated by vacuum operations performed on this database

wal_fpiint8

Total number of WAL full page images generated by vacuum operations performed on this database

wal_bytesnumeric

Total amount of WAL bytes generated by vacuum operations performed on this database

blk_read_timefloat8

Time spent reading database blocks by vacuum operations performed on this database, in milliseconds (if track_io_timing is enabled, otherwise zero)

blk_write_timefloat8

Time spent writing database blocks by vacuum operations performed on this database, in milliseconds (if track_io_timing is enabled, otherwise zero)

delay_timefloat8

Time spent sleeping in a vacuum delay point by vacuum operations performed on this database, in milliseconds (see Section 18.4.4 for details)

system_timefloat8

System CPU time of vacuuming this database, in milliseconds

user_timefloat8

User CPU time of vacuuming this database, in milliseconds

total_timefloat8

Total time of vacuuming this database, in milliseconds

interruptsint4

Number of times vacuum operations performed on this database were interrupted on any errors


Note

On upgrading your server just by replacing the executables, update the pg_stats_vacuum_database view as superuser who ran initdb:

  • For each database, including template1, but not including template0, run:

     CREATE OR REPLACE VIEW pg_stats_vacuum_database AS SELECT db.oid as dboid, stats.db_blks_read, stats.db_blks_hit, stats.total_blks_dirtied, stats.total_blks_written, stats.wal_records, stats.wal_fpi, stats.wal_bytes, stats.blk_read_time, stats.blk_write_time, stats.delay_time, stats.system_time, stats.user_time, stats.total_time, stats.interrupts FROM pg_database db LEFT JOIN pg_stats_vacuum_database(db.oid) stats ON db.oid = stats.dboid; 

  • For the template0 database, run:

     \c template1 ALTER DATABASE template0 ALLOW_CONNECTIONS on; \c template0 CREATE OR REPLACE VIEW pg_stats_vacuum_database AS SELECT db.oid as dboid, stats.db_blks_read, stats.db_blks_hit, stats.total_blks_dirtied, stats.total_blks_written, stats.wal_records, stats.wal_fpi, stats.wal_bytes, stats.blk_read_time, stats.blk_write_time, stats.delay_time, stats.system_time, stats.user_time, stats.total_time, stats.interrupts FROM pg_database db LEFT JOIN pg_stats_vacuum_database(db.oid) stats ON db.oid = stats.dboid; \c template1 ALTER DATABASE template0 ALLOW_CONNECTIONS off; 

close