Skip to content

Instantly share code, notes, and snippets.

@drob
Created May 20, 2014 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drob/4923ab4ab569c9770aee to your computer and use it in GitHub Desktop.
Save drob/4923ab4ab569c9770aee to your computer and use it in GitHub Desktop.
SELECT
nspname,
relname,
dead_tuples,
autovacuum_threshold,
dead_tuples > autovacuum_threshold AS overdue
FROM (
SELECT
nspname,
relname,
pg_stat_get_dead_tuples(pg_class.oid) AS dead_tuples,
round(current_setting('autovacuum_vacuum_threshold')::INTEGER
+ current_setting('autovacuum_vacuum_scale_factor')::NUMERIC * reltuples) AS autovacuum_threshold
FROM pg_class, pg_namespace
WHERE pg_class.relnamespace = pg_namespace.oid
) t
ORDER BY overdue DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment