Postgresql how to get database size

Postgresql how to get database size

Colleagues hello to all.

In today's short article, I'll show you a couple of queries that show the size of all databases or a single database in Postgresql.

 

The first query shows the size of each database.

psql> SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;

postgresql_database_size

 

The second query shows the size of the database, the name we specify.

psql> SELECT pg_size_pretty(pg_database_size('demo'));

postgresql_database_size


 

Thank you all, I hope that my article helped you in some way.

SIMILAR ARTICLES

PostgreSQL - How to determine which files on disk correspond to tables in a database
PostgreSQL - How to determine which files on disk correspond to tables in a database
POSTGRESQL
Read more
PostgreSQL - How to find out the size of tables in a database
PostgreSQL - How to find out the size of tables in a database
POSTGRESQL
Read more
PostgreSQL - How to check user privileges
PostgreSQL - How to check user privileges
POSTGRESQL
Read more