Today I Learned

hashrocket A Hashrocket project

Get The Size Of A Database

If you have connect access to a PostgreSQL database, you can use the pg_database_size() function to get the size of a database in bytes.

> select pg_database_size('hr_hotels');
 pg_database_size
------------------
          8249516

Just give it the name of the database and it will tell you how much disk space that database is taking up.

Checkout the Postgres docs for more details.

See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.