Re: How can I know the disk space used by a table?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: andrea(dot)aime(at)comune(dot)modena(dot)it
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I know the disk space used by a table?
Date: 2001-08-07 14:51:15
Message-ID: 2394.997195875@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Andrea Aime" <aaime(at)comune(dot)modena(dot)it> writes:
> is there any way to have an estimate of the disk space used by a table?

(1) VACUUM foo;

(2) SELECT relpages * 8 FROM pg_class WHERE relname = 'foo';

This gives you the actual file size in kilobytes. (The magic number 8
assumes you are using the default BLCKSZ of 8K, else adjust to match.)

You need the VACUUM step to be sure the relpages field is up to date;
it's not updated during normal operations.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2001-08-07 15:27:44 Re: Still wondering about random numbers...
Previous Message Daniel Åkerud 2001-08-07 14:39:42 Transactions and timestamps