How to quickly parse postgres database

I have a postgres database that I want to know about quick statistics. For example, which tables are taking up the most space? I don't need anything, I need the command line. What is a good tool for this?

+3


source to share


3 answers


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;

      

+4


source


From the psql client program, "\ l" will list the databases, add "+" to show sizes as well: "\ l +". In addition, "\ dt +" will give you information about the specific dimensions of the table.



+2


source


Interest Ask. I think you can query information using psql. Here are some pointers.

http://securfox.wordpress.com/2009/09/02/how-to-find-the-postgresql-database-size/ and http://heatware.net/databases/find-postgresql-database-size-using -sql-select / .

Hope this helps.

Thank you, Shankar

+1


source







All Articles