Re: How can I known the size of a database, table by table - Mailing list pgsql-general

From Steve Crawford
Subject Re: How can I known the size of a database, table by table
Date
Msg-id 44282957.2070508@pinpointresearch.com
Whole thread Raw
In response to How can I known the size of a database, table by table ?  (Bruno Baguette <pgsql-ml@baguette.net>)
List pgsql-general
Bruno Baguette wrote:
> Hello,
>
> I works on a PostgreSQL 8.0.4 database, and I would like to known the
> size (in bytes, Mbytes or anything else) of that database, for each table.
>
> How can I do that ?
>
> Thanks in advance !
>

This will probably work for you (in bytes - or you could divide by 8
instead for KB):

select relpages*8192 from pg_class where relname = 'your_table_name';

8k page size is typical but you may need to verify this for your system.
Also, there may be toast tables associated with your main table so you
could need to add their sizes to your total for the table.

See the manual section on monitoring disk usage for more
complete/accurate info:
http://www.postgresql.org/docs/8.1/interactive/diskusage.html


Cheers,
Steve

pgsql-general by date:

Previous
From: Leon Pu
Date:
Subject: Re: PostgreSQL support on Redhat Advance Server 2.1
Next
From: Kevin Murphy
Date:
Subject: Re: How can I known the size of a database, table by table ?