Re: a fast bloat measurement tool (was Re: Measuring relation free space)

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Abhijit Menon-Sen <ams@2ndquadrant.com>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2014-04-03T00:10:54Z
Lists: pgsql-hackers
On Wed, Apr 2, 2014 at 5:41 PM, Abhijit Menon-Sen <ams@2ndquadrant.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