From: | Rod Taylor <rbt(at)rbt(dot)ca> |
---|---|
To: | PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Free Space? |
Date: | 2003-05-21 02:45:32 |
Message-ID: | 1053485131.33651.13.camel@jester |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I was poking around to see if you can come up with an estimate for free
space in a table... Not having much luck..
Best I found was the below, which is only anywhere near close on tables
that store stats on all columns -- which isn't normal.
select relname
, relpages * 8192 as spaceused
, relpages * (8192 - 20)
- (reltuples * (
coalesce((select sum(stawidth * (1 - stanullfrac))
from pg_statistic
where starelid = pg_class.oid)
, 0) + 23)
) as freespace
from pg_class
where relkind in ('r');
--
Rod Taylor <rbt(at)rbt(dot)ca>
PGP Key: http://www.rbt.ca/rbtpub.asc
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-05-21 04:23:47 | Re: Logging (was Re: Suggestion GRANT ALTER, TRIGGER ON ALTER) |
Previous Message | Christopher Kings-Lynne | 2003-05-21 01:53:04 | Re: Logging (was Re: Suggestion GRANT ALTER, TRIGGER ON ALTER) |