Sunday, May 13, 2012

A script to see row counts and table size in PostgreSQL

Here is a little perl script that I use to give me a list of tables in a schema, a rowcount and the pg_relation_size of a table. The usage is just:
pg_rowcount <database> <schema>
ex: ./pg_rowcount.pl david.kerr pg_catalog
The output looks like this:
Table                                Rows                 Size
--------------------------------------------------------------
pg_statistic                         1853              1672 kB
pg_type                               910               168 kB
pg_attribute                         9569              1488 kB
pg_class                             1371               416 kB
pg_authid                              52                16 kB
pg_index                              766               112 kB
pg_operator                           705               104 kB
pg_database                            44                16 kB
[...]
You can download the script here

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Web Statistics