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;
The second query shows the size of the database, the name we specify.
psql> SELECT pg_size_pretty(pg_database_size('demo'));
Thank you all, I hope that my article helped you in some way.