Skip to content

Instantly share code, notes, and snippets.

@tammoippen
Created September 15, 2021 15:23
Show Gist options
  • Save tammoippen/33bc85602fcbc2280097fabb040c26ed to your computer and use it in GitHub Desktop.
Save tammoippen/33bc85602fcbc2280097fabb040c26ed to your computer and use it in GitHub Desktop.
List the size of all tables in postgresql
SELECT
schemaname,
tablename,
PG_SIZE_PRETTY(
PG_TOTAL_RELATION_SIZE(schemaname || '.' || tablename)
) AS tablesize
FROM
pg_catalog.pg_tables
WHERE
schemaname NOT IN ('pg_catalog', 'information_schema')
ORDER BY
PG_TOTAL_RELATION_SIZE(schemaname || '.' || tablename) DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment