Skip to content

Instantly share code, notes, and snippets.

@cnnrrss
Created February 20, 2024 19:20
Show Gist options
  • Save cnnrrss/ff683ca10cfb4845b1a20f125c724e41 to your computer and use it in GitHub Desktop.
Save cnnrrss/ff683ca10cfb4845b1a20f125c724e41 to your computer and use it in GitHub Desktop.
Find empty tables in Postgres
SELECT
t.tablename
FROM
pg_catalog.pg_tables t
LEFT JOIN pg_stat_user_tables stat ON t.tablename = stat.relname
WHERE
t.schemaname = 'public' -- Adjust this to your schema name if different
AND stat.n_live_tup = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment