Re: Primary Key Index Bloat?

From: Chris Ernst <cernst(at)zvelo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Primary Key Index Bloat?
Date: 2013-11-18 13:38:54
Message-ID: 528A186E.50202@zvelo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/17/2013 11:48 PM, David Johnston wrote:
> I am guessing that it is the need for the index to point to new versions of
> the physical record that the index is churning so much and causing this kind
> of bloat?

Bingo.

> I am preparing to REINDEX the unique index and DROP the non-unique one over
> the same field - probably Tuesday evening. Does everything I am saying here
> sound kosher or would someone like me to provide additional information?
...
> I have mostly left VACUUMing to auto-vacuum though the occasional manual one
> has been performed. Never performed VACUUM FULL.

REINDEX will only rebuild the indexes (obviously) and VACUUM FULL would
clean up any bloat in the indexes and the table itself. Either would
require an exclusive lock on the table.

If the exclusive lock is a problem, you might look in to pg_repack as an
option as well. It essentially recreates the table in parallel then
swaps in the newly built one. It only requires an exclusive lock for a
moment.

- Chris

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Janek Sendrowski 2013-11-18 15:34:44 Regex files are missing
Previous Message Rafael Martinez 2013-11-18 11:12:18 Could not truncate directory "pg_subtrans": apparent wraparound