Database Size

Determining Size of Databases on PostgreSQL Server on AWS

Selecting the Database Size

Selecting the size of your databases in Postgresql can be done with the following script:

select datname as db_name, pg_database_size(datname) from pg_database;

Selecting the Database Size on AWS RDS

If you are using Amazon Web Services AWS - RDS for PostgreSQL then you don't have access to the rdsadmin table. It must be excluded from the results as follows:

select db_name,pg_database_size(db_name) database_size, pg_size_pretty(pg_database_size(db_name)) as

database_size_pretty from

(select datname as db_name, pg_database_size(datname) from pg_database

where datname <>'rdsadmin') x

order by database_size