Skip to content

PopSQL: limited support.

Migrate now →

Dead tuples by table

Tables where dead rows pile up against live ones. Above 20% the autovacuum is losing; above 50% reads are paying for it.

PostgreSQL · SQL
SELECT schemaname || '.' || relname AS table_name,
       n_live_tup AS live_rows,
       n_dead_tup AS dead_rows,
       ROUND(100.0 * n_dead_tup / NULLIF(n_live_tup + n_dead_tup, 0), 1) AS dead_pct,
       last_autovacuum,
       last_vacuum
FROM pg_stat_user_tables
WHERE n_live_tup + n_dead_tup > 1000
ORDER BY n_dead_tup DESC
LIMIT 25

This query is part of the "PostgreSQL health" pack: connect the database in DataRunner and install the whole pack — queries, dashboard and checks — at once.