Re: Online index builds

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ragnar <gnari(at)hive(dot)is>, pgsql-general(at)postgresql(dot)org
Subject: Re: Online index builds
Date: 2006-12-08 01:07:57
Message-ID: 1165540077.13953.20.camel@dogma.v10.wvs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-general pgsql-www

On Thu, 2006-12-07 at 19:44 -0500, Tom Lane wrote:
> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> > I don't understand. CREATE INDEX CONCURRENTLY can't be run in a
> > transaction block anyway, so a REINDEX CONCURRENTLY wouldn't either. So
> > how (or when) would you deadlock?
>
> The problem is you need to upgrade from a nonexclusive table lock to an
> exclusive one before you could drop the old index. If someone else
> is waiting to get a conflicting lock, boom ...
>

I think what I'm confused about is how these non-transactional commands
work (like VACUUM, etc). Are they still transactions, and just can't be
run in a block?

My original thinking was that the shared lock could be unlocked before
the exclusive lock is taken to switch the relfilenodes and to drop the
index. However, if it is a real transaction, clearly you can't unlock in
the middle.

Is it safe to manually run the sequence I previously suggested? If so it
seems like there could be a command to do it properly. I tried it and it
appeared to work.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-announce by date

  From Date Subject
Next Message navicat 2006-12-08 10:17:44 PremiumSoft releases Navicat PostgreSQL GUI for Windows (ver. 7.2.9)
Previous Message Tom Lane 2006-12-08 00:44:10 Re: Online index builds

Browse pgsql-general by date

  From Date Subject
Next Message Scott Ribe 2006-12-08 03:46:23 Re: Restore database from files (not dump files)?
Previous Message Tom Lane 2006-12-08 00:44:10 Re: Online index builds

Browse pgsql-www by date

  From Date Subject
Next Message Jim Nasby 2006-12-09 02:04:08 Re: Broken link to 8.2 release notes
Previous Message Tom Lane 2006-12-08 00:44:10 Re: Online index builds