Free Space? - Mailing list pgsql-hackers

From Rod Taylor
Subject Free Space?
Date
Msg-id 1053485131.33651.13.camel@jester
Whole thread Raw
Responses Re: Free Space?  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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((selectsum(stawidth * (1 - stanullfrac))                      from pg_statistic                     where
starelid= pg_class.oid)                  , 0) + 23)        ) as freespace from pg_classwhere relkind in ('r'); 

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Re: Logging (was Re: Suggestion GRANT ALTER, TRIGGER ON ALTER)
Next
From: Tom Lane
Date:
Subject: Re: Free Space?