1

I need to clear disk space, so I want to see which tables and other objects are using the most disk space in my Postgres databases.

Ideally, I'd like to see: database name, schema name, object type, object name and size in GB/MB. I'm imagining something like the du -h command or the ncdu utility but for Postgres.

Is there a command to do this in psql? I know about \l+ {database name} but this just gives me the size of the database, not the objects within it.

1

1 Answer 1

1

This is the hit list of the largest objects in your database:

SELECT oid::regclass,
       pg_relation_size(oid),
       relkind
FROM pg_class
ORDER BY 2 DESC;

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.