Thread: BUG #13426: table bloat - dead rows not removed after vacuum

BUG #13426: table bloat - dead rows not removed after vacuum

From
jkoceniak@mediamath.com
Date:
The following bug has been logged on the website:

Bug reference:      13426
Logged by:          Jamie
Email address:      jkoceniak@mediamath.com
PostgreSQL version: 9.1.14
Operating system:    x86_64-unknown-linux-gnu debian
Description:

I have a table that is growing out of control.

After doing a vacuum, the dead rows still remain. Why can't they be
removed?

DETAIL:  214063622 dead row versions cannot be removed yet.

Re: BUG #13426: table bloat - dead rows not removed after vacuum

From
"David G. Johnston"
Date:
On Wed, Jun 10, 2015 at 10:02 AM, <jkoceniak@mediamath.com> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      13426
> Logged by:          Jamie
> Email address:      jkoceniak@mediamath.com
> PostgreSQL version: 9.1.14
> Operating system:    x86_64-unknown-linux-gnu debian
> Description:
>
> I have a table that is growing out of control.
>
> After doing a vacuum, the dead rows still remain. Why can't they be
> removed?
>
> DETAIL:  214063622 dead row versions cannot be removed yet.
>

=E2=80=8BOne possibility is that =E2=80=8B
you have a long-running transaction holding up cleanup.

Viewing "pg_stat_activity" will be informative.

=E2=80=8BDavid J.

Re: BUG #13426: table bloat - dead rows not removed after vacuum

From
Jamie Koceniak
Date:
SGkgRGF2aWQsDQoNCk5vIGxvbmcgcnVubmluZyBxdWVyaWVzIGFyZSBpbiBwZ19zdGF0X2FjdGl2
aXR5Lg0KSSB3YXMgYWxzbyBhYmxlIHRvIHRha2UgdGhpcyBzYW1lIHRhYmxlIGFuZCBpbXBvcnQg
b250byBhbm90aGVyIHNlcnZlciwgcGVyZm9ybSBtaWxsaW9ucyBvZiBkZWxldGVzIGFuZCBpbnNl
cnRzIHRvIHJlY3JlYXRlIHRoZSBwcm9ibGVtLg0KVGhlIOKAmFZhY3V1bSB0YWJsZW5hbWXigJgg
Y29tbWFuZCBpcyBub3QgcmVtb3ZpbmcgZGVhZCByb3cgdmVyc2lvbnMuDQoNClRoYW5rcyBmb3Ig
dGhlIHF1aWNrIHJl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VhZCByb3cgdmVyc2lvbnMgY2Fubm90IGJlIHJlbW92ZWQgeWV0Lg0KDQrigItPbmUgcG9zc2li
aWxpdHkgaXMgdGhhdCDigIsNCnlvdSBoYXZlIGEgbG9uZy1ydW5uaW5nIHRyYW5zYWN0aW9uIGhv
bGRpbmcgdXAgY2xlYW51cC4NCg0KVmlld2luZyAicGdfc3RhdF9hY3Rpdml0eSIgd2lsbCBiZSBp
bmZvcm1hdGl2ZS4NCg0K4oCLRGF2aWQgSi4NCg0K

Re: BUG #13426: table bloat - dead rows not removed after vacuum

From
Kevin Grittner
Date:
Jamie Koceniak <jkoceniak@mediamath.com> wrote:
> David G. Johnston [mailto:david.g.johnston@gmail.com] wrote:

>> One possibility is that you have a long-running transaction
>> holding up cleanup.

> No long running queries are in pg_stat_activity.

It doesn't take a long-running *query* to cause a problem; it only
takes a long-running *transaction*.  Look for transactions which
are "idle in transaction" with an old xact_start value.  Also check
the pg_prepared_xacts view for rows with a "prepared" value that is
more than a few seconds old.  Either will prevent the cleanup of
dead rows.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company