Get Postgresql table sizes

Postgresql table sizes

PostgreSQL has lots and lots of sweet internals but its not always easy to know how to find them. Here is an simple way of getting the disk size of a PostgreSQL table.

From within the database of choice.

Run the following query to get some useful table statistics.

1
SELECT relname, reltuples, relpages * 8 / 1024 AS “MB” FROM pg_class ORDER BY relpages DESC;

From: http://www.pastbedti.me/2008/03/postgresql-table-sizes/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s