Re: Bloated Table - Mailing list pgsql-general

From Tom Lane
Subject Re: Bloated Table
Date
Msg-id 15351.1243452491@sss.pgh.pa.us
Whole thread Raw
In response to Re: Bloated Table  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Bloated Table
Re: Bloated Table
List pgsql-general
Alvaro Herrera <alvherre@commandprompt.com> writes:
> Brad Nicholson wrote:
>> On Wed, 2009-05-27 at 11:15 -0400, Tom Lane wrote:
>>> I wouldn't trust the calculations that view does in the least.

> If "ma" is supposed to be "maxalign", then this code is broken because
> it only reports mingw32 as 8, all others as 4, which is wrong.

I didn't bother to go through every detail of the calculations, but
there are multiple small errors there.  (Handling alignment for the
tuple header and not anyplace else is pretty pointless, for instance,
even if you had the correct alignment number for the machine.)
However ...

> However I think the big problem is that it relies on pg_class.relpages
> and reltuples which are only accurate just after VACUUM, only a
> sample-based estimate just after ANALYZE, and wrong at any other time
> (assuming the table has any movement).

That's big problem number one, and big problem number two is that it has
no good idea of the width of variable-width fields.  (Should I even
mention TOAST?)

It's an interesting exercise in trying to estimate bloat without
groveling through the whole relation, but I seriously doubt you could
ever get numbers this way that are trustworthy enough to drive
maintenance decisions.

            regards, tom lane

pgsql-general by date:

Previous
From: Kevin Kempter
Date:
Subject: Re: [PERFORM] Postgres Clustering
Next
From: Alan McKay
Date:
Subject: Re: [PERFORM] Postgres Clustering