Getting the Size of a Postgresql Database

Get size of postgresql Database

To get the size of a table go into psql and use the following command:

SELECT pg_database_size(‘db_name’);

Simpley replace db_name with the name of the database you want to get the size of and it will return the size in bytes.

The above command shows you the size in bytes which is difficult to read on larger databases, so use the human readable size function like this to get it in a more friendly format:

SELECT pg_size_pretty(pg_database_size(‘db_name’));

Leave a Reply

Your email address will not be published. Required fields are marked *