1

I know how to find relation and database size using pg_total_relation_size(), and pg_database_size(). But I want to find whole cluster size. Is there a way other than calculating disk space of data directory using file manager or using a query like this?

SELECT pg_size_pretty(sum(pg_database_size(datname))) AS "total databases size"
FROM pg_database;

1 Answer 1

2

There is also pg_tablespace_size():

SELECT pg_size_pretty(sum(pg_tablespace_size(oid))) AS "total cluster size"
FROM pg_tablespace;    

It should report slightly more than the sum of database sizes as it also includes global objects (which don't normally account for much).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.