On Wed, Apr 2, 2014 at 5:41 PM, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com> wrote:
> I've attached an extension that produces largely pgstattuple-compatible
> numbers for a table without doing a full-table scan.
>
> It scans through the table, skipping blocks that have their visibility
> map bit set. For such pages, it gets the free space from the free space
> map, and assumes that all remaining space on the page is taken by live
> tuples. It scans other pages tuple-by-tuple and counts live and dead
> tuples and free space.
That's clever. I think it might underestimate free space relative to
tuples because the free space map isn't guaranteed to be completely
correct. But I guess you knew that already...
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company