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; ...

Get PostgreSQL High Performance Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.