Re: How can I know the disk space used by a table? - Mailing list pgsql-general

From Tom Lane
Subject Re: How can I know the disk space used by a table?
Date
Msg-id 2394.997195875@sss.pgh.pa.us
Whole thread Raw
In response to How can I know the disk space used by a table?  ("Andrea Aime" <aaime@comune.modena.it>)
List pgsql-general
"Andrea Aime" <aaime@comune.modena.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

pgsql-general by date:

Previous
From: Daniel Åkerud
Date:
Subject: Transactions and timestamps
Next
From: "Joe Conway"
Date:
Subject: Re: Still wondering about random numbers...