Created
February 27, 2024 21:03
-
-
Save shadyrudy/1b9e7620bb06393639245229ab8b9a29 to your computer and use it in GitHub Desktop.
PostgreSQL - Tables modified since last vacuum.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT n.nspname AS schema_name | |
,c.relname AS table_or_index_name | |
,c.relkind AS table_or_index | |
,c.reltuples AS row_count | |
,s.last_vacuum | |
,s.last_autovacuum | |
,s.last_analyze | |
,s.last_autoanalyze | |
FROM pg_class c | |
JOIN pg_namespace n ON n.oid = c.relnamespace | |
LEFT JOIN pg_stat_user_tables s ON s.relid = c.oid | |
WHERE n.nspname not in ('pg_catalog', 'information_schema') | |
AND | |
( | |
c.relkind = 'r' | |
OR c.relkind = 'i' | |
) | |
AND ( | |
s.last_vacuum < s.last_autovacuum | |
OR s.last_vacuum < s.last_analyze | |
) | |
order by n.nspname, c.relname; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment