PostgreSQL - Get junk table names
The following code returns unused Postgres tables.
SELECT pg_stat_user_tables.relname FROM pg_stat_user_tables, pg_statio_user_tables WHERE pg_statio_user_tables.schemaname='public' AND (pg_statio_user_tables.heap_blks_read=0 OR pg_statio_user_tables.heap_blks_read IS NULL) AND pg_stat_user_tables.n_tup_ins=0 AND pg_stat_user_tables.n_tup_del=0 AND pg_stat_user_tables.n_tup_upd=0 AND pg_statio_user_tables.relname=pg_stat_user_tables.relname
