Re: Table size

From: Jim Nasby <decibel(at)decibel(dot)org>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Shyam Sunder Rai <ssrai(at)ismartpanache(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Table size
Date: 2007-06-18 22:18:54
Message-ID: F8EF74FD-0F4E-4D26-A80F-844CB5A67A0A@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Jun 14, 2007, at 8:16 AM, Michael Fuhr wrote:
> On Thu, Jun 14, 2007 at 06:10:15PM +0530, Shyam Sunder Rai wrote:
>> How can I calculate a table size in postgres ?
>
> To find the size of an existing table use pg_relation_size() or
> pg_total_relation_size() (8.1 and later; in earlier versions use
> the functions in contrib/dbsize).

If you don't need an exact size, you can also look at
pg_class.relpages, which is the size of a relation in pages. The
relation_size functions actually read the size off the filesystem,
which seems to be quite a bit slower if you're dealing with more than
a few files.
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message John Meyer 2007-06-19 03:02:07 Re: [GENERAL] [PERFORM] [ADMIN] Postgres VS Oracle
Previous Message Jim Nasby 2007-06-18 22:16:23 Re: How to restore updated records