Monitoring vacuum progress
In this recipe, we will be discussing the usage of the pg_stat_progress_vacuum
catalog view, which gives some metrics about the ongoing vacuum process.
Getting ready
PostgreSQL 9.6 introduces a new catalog view, which provides some metrics about the ongoing vacuum processes. This view provides some metrics, along with different action phases, where vacuum/autovacuum performs internally on the table. This view currently does not track the metrics of VACUUM FULL
operations, which might be available in future versions.
How to do it...
Let use VACUUM
on any sample big table:
benchmarksql=# VACUUM bigtable;
In another terminal, let us query the view and put in the \watch
mode, as shown here:
benchmarksql=# SELECT * FROM pg_stat_progress_vacuum;
(0 rows)
benchmarksql=# \watch 1 -[ RECORD 1 ]------+------------------ pid | 4785
datid | 16405
datname | benchmarksql
relid | 16762
phase | scanning...