Re: How can I known the size of a database, table by table

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Bruno Baguette <pgsql-ml(at)baguette(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I known the size of a database, table by table
Date: 2006-03-27 18:05:11
Message-ID: 44282957.2070508@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Murphy 2006-03-27 18:59:47 Re: How can I known the size of a database, table by table ?
Previous Message Leon Pu 2006-03-27 18:03:27 Re: PostgreSQL support on Redhat Advance Server 2.1