script to find postgres db size:
SELECT
pg_database.datname,
pg_size_pretty(pg_database_size(pg_database.datname)) AS size
FROM pg_database;
postgres=# \l+ postgres
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
----------+----------+-----------+---------+-------+------------------------+---------+------------+--------------------------------------------
postgres | postgres | SQL_ASCII | C | C | =Tc/postgres +| 7941 kB | pg_default | default administrative connection database
| | | | | postgres=CTc/postgres +| | |
| | | | | kmonitor00=c/postgres +| | |
| | | | | testmonitor=c/postgres | | |
(1 row)
select t1.datname AS db_name,
pg_size_pretty(pg_database_size(t1.datname)) as db_size
from pg_database t1
order by pg_database_size(t1.datname) desc;
datname | size
----------------------+---------
testdbTest | 7941 kB
template1 | 7941 kB
template0 | 7801 kB
testdba | 7941 kB
No comments:
Post a Comment