Database size of a PostgreSQL server instance

How to obtain the database size of a PostgreSQL Server instance?

Database query

With this query you can check the size of each database.

select datname AS DatabaseName,
pg_size_pretty(pg_database_size(datname)) as Size
from pg_database order by
pg_database_size(datname) desc;

The units are shown in the query result (kB, MB, …).

Leave a Reply

Your email address will not be published.