Sunday, 21 January 2024

PostgreSQL: Check the progress of running VACUUM

 In this post, I am sharing a system view which we can use to check the progress of running vacuum process of PostgreSQL.

PostgreSQL based on MVCC, and in this architecture VACUUM is a routine task of DBA for removing dead tuples.


Now the question is, How to monitor the progress of VACUUM?

Simple, we can use pg_stat_progress_vacuum view for this purpose. In this view, we can check phase column which indicates the different stages of running the vacuum.

Type of phases:

initializing: VACUUM is preparing to begin scanning the heap
scanning heap: VACUUM is currently scanning the heap
vacuuming indexes: VACUUM is currently vacuuming the indexes
vacuuming heap: VACUUM is currently vacuuming the heap
cleaning up indexes: VACUUM is currently cleaning up indexes
truncating heap: VACUUM is currently truncating the heap to return empty pages at the end of the relation to the operating system
performing final cleanup: VACUUM is performing final cleanup. During this phase, VACUUM will vacuum the free space map, update statistics in pg_class, and report statistics to the statistics collector

No comments:

Post a Comment

Master and Slave - Sync check - PostgreSQL

  1) Run the below Query on Primary:- SELECT     pid,     usename,     application_name,     client_addr,     state,     sync_state,     sen...