Hey what is up, figured I my tis well be the first one to put something in here.

How to find the PostgreSQL database size

PostgreSQL is a powerful, open source relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.
If you want to find the size of a database, in our example the sqview database, please tape:sqview-# SELECT pg_database_size(‘sqview’);
pg_database_size
——————
111415944
(1 ligne)

The result in octal, for a pretty print we will use the pg_size_pretty function which converts the size in bytes to human understandable format.sqview-# SELECT pg_size_pretty(pg_database_size(‘sqview’));
pg_size_pretty
—————-
106 MB
(1 ligne)

This value exclude indexes and some auxiliary data.
If you want to include them use pg_total_relation_size instead of pg_relation_size as shown below.sqview-# SELECT pg_size_pretty(pg_total_relation_size(‘users’));
pg_size_pretty
—————-
152 kB
(1 ligne)

SELECT d.datname AS Name, pg_catalog.pg_get_userbyid(d.datdba) AS Owner,
pg_catalog.pg_database_size(d.datname)/1024/1024 as size_in_MB,
CONCAT(pg_catalog.pg_database_size(d.datname)/1024/1024, ‘ MB’) as size_in_MB
FROM pg_catalog.pg_database d
WHERE d.datname ‘rdsadmin’ and d.datname ‘template0’ and d.datname ‘template1’ and d.datname ‘postgres’
ORDER BY pg_catalog.pg_database_size(d.datname) DESC;