how to quickly analyze a postgres database
postgresql
Solution
The functions you want are here:
http://www.postgresql.org/docs/current/interactive/functions-admin.html#FUNCTIONS-ADMIN-DBSIZE
A quick query to find the top 20 tables in terms of space usage might look like this:
SELECT oid::regclass, pg_size_pretty(pg_total_relation_size(oid))
FROM pg_class
WHERE relkind = 'r'
ORDER BY pg_total_relation_size(oid) DESC
LIMIT 20;
Problem
I have a postgres database that I want to know some quick stats. For instance, which tables are taking up the most space? I don't need anything fancy, command line is all I need. What is a good tool for this?