Re: Support for REINDEX CONCURRENTLY

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Simon Riggs <simon(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Support for REINDEX CONCURRENTLY
Date: 2012-12-10 06:03:59
Message-ID: CAB7nPqRNRRYDrRmLVp0ZiE5NWP26ZiGrT3BTT-HXVo5Pz7EmBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I have updated the patch (v4) to take care of updating reltoastidxid for
toast parent relations at the swap step by using index_update_stats. In
prior versions of the patch this was done when concurrent index was built,
leading to toast relations using invalid indexes if there was a failure
before the swap phase. The update of reltoastidxids of toast relation is
done with RowExclusiveLock.
I also added a couple of tests in src/test/isolation. Btw, as for the time
being the swap step uses AccessExclusiveLock to switch old and new
relnames, it does not have any meaning to run them...

On Sat, Dec 8, 2012 at 11:55 PM, Andres Freund <andres(at)2ndquadrant(dot)com>wrote:

> On 2012-12-08 09:40:43 -0500, Tom Lane wrote:
> > Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > I'm tempted to propose that REINDEX CONCURRENTLY simply not try to
> > preserve the index name exactly. Something like adding or removing
> > trailing underscores would probably serve to generate a nonconflicting
> > name that's not too unsightly. Or just generate a new name using the
> > same rules that CREATE INDEX would when no name is specified. Yeah,
> > it's a hack, but what about the CONCURRENTLY commands isn't a hack?
>
> I have no problem with ending up with a new name or something like
> that. If that is what it takes: fine, no problem.
>
For the indexes that are created internally by the system like toast or
internal primary keys this is acceptable. However in the case of indexes
that have been created externally I do not think it is acceptable as this
impacts the user that created those indexes with a specific name.

pg_reorg itself also uses the relname switch method when rebuilding indexes
and people using it did not complain about the heavy lock taken at swap
phase, but praised it as it really helps in reducing the lock taken for
reindex at index rebuild and validation, which are the phases that take the
largest amount of time in the REINDEX process btw.
--
Michael Paquier
http://michael.otacoo.com

Attachment Content-Type Size
20121210_reindex_concurrently_v4.patch application/octet-stream 62.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2012-12-10 08:26:23 Re: [BUG?] lag of minRecoveryPont in archive recovery
Previous Message Shigeru Hanada 2012-12-10 05:27:40 Re: PATCH: optimized DROP of multiple tables within a transaction