PostgreSQL how to get database size

  • Last updated: Oct 10, 2024
  • Views: 11
  • Author: Admin
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