psql -d appdb -c "SELECT relname, n_live_tup, n_dead_tup FROM pg_stat_user_tables ORDER BY n_dead_tup DESC;"

Category: Databases & SQL

psql -d appdb -c "SELECT relname, n_live_tup, n_dead_tup FROM pg_stat_user_tables ORDER BY n_dead_tup DESC;"

Rank tables by dead tuples

Ranks user tables by dead tuples, the rows awaiting cleanup by autovacuum. A table with a huge dead count is a candidate for manual VACUUM and ANALYZE. Statistics are approximate until refreshed.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.