This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a script to find a list of tables with the information like the last action_date of VACUUM and ANALYZE in Greenplum.
Before executing VACUUM or ANALYZE on tables, we should check the last execution time of it. If it recently executed, we should skip those tables for VACUUM or ANALYZE.
In below script, I am finding this information from pg_stat_last_operation.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
select pn.nspname ,pc.relname ,pslo.staactionname ,pslo.stasubtype ,pslo.statime as action_date from pg_stat_last_operation pslo right outer join pg_class pc on pc.oid = pslo.objid and pslo.staactionname in ('VACUUM','ANALYZE') join pg_namespace pn on pn.oid = pc.relnamespace where pc.relkind IN ('r','s') AND pc.relstorage IN ('h', 'a', 'c'); |
Leave a Reply