Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rcanepa/ccd19def00d4844f7c74a4606ce9b467 to your computer and use it in GitHub Desktop.
Save rcanepa/ccd19def00d4844f7c74a4606ce9b467 to your computer and use it in GitHub Desktop.
PostgreSQL database and tables sizes
------------------
From psql
------------------
- Check all database sizes
\l+
- Connect to database DBNAME
\connect DBNAME
- Check the table sizes from database DBNAME
\d+
------------------
As a SQL statement
------------------
- Database Size
SELECT pg_size_pretty(pg_database_size('Database Name'));
- Table Size
SELECT pg_size_pretty(pg_relation_size('table_name'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment