Skip site navigation (1) Skip section navigation (2)

Re: disabling an index without deleting it?

From: "Markus Bertheau" <mbertheau(dot)pg(at)googlemail(dot)com>
To: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, "Peter Koczan" <pjkoczan(at)gmail(dot)com>, pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: disabling an index without deleting it?
Date: 2008-02-27 05:29:55
Message-ID: 684362e10802262129w4fe41264p1eb75cadd5f4d259@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
2008/2/27, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>:
> On Tue, Feb 26, 2008 at 10:48 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>  > "Markus Bertheau" <mbertheau(dot)pg(at)googlemail(dot)com> writes:
>  >  > 2008/2/27, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>  >
>  > >> No, what makes you think that?  The index won't change at all in the
>  >  >> above example.  The major problem is, as Scott says, that DROP INDEX
>  >  >> takes exclusive lock on the table so any other sessions will be locked
>  >  >> out of it for the duration of your test query.
>  >
>  >  > Why is the exclusive lock not taken later, so that this method can be
>  >  > used reasonably risk-free on production systems?
>  >
>  >  Er, later than what?  Once the DROP is pending, other transactions can
>  >  hardly safely use the index for lookups, and what should they do about
>  >  insertions?
>
>
> I see what you're saying.  Sadly, my dreams of drop index concurrently
>  appear dashed.

Maybe a different syntax: DROP INDEX DEFERRED, which will make the
current transaction behave as if the index was dropped but not
actually drop it until the end of the transaction. Inserts and updates
of this and other transactions behave as if the index existed.

On the other hand, if the only reason to have that feature is to plan
and execute queries pretending that one index doesn't exist, then DROP
INDEX DEFERRED is not the most straightforward syntax.

Markus

-- 
Markus Bertheau
Blog: http://www.bluetwanger.de/blog/

In response to

Responses

pgsql-performance by date

Next:From: Tom LaneDate: 2008-02-27 05:38:49
Subject: Re: disabling an index without deleting it?
Previous:From: Scott MarloweDate: 2008-02-27 05:16:54
Subject: Re: disabling an index without deleting it?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group