"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