Re: disabling an index without deleting it?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>, "Markus Bertheau" <mbertheau(dot)pg(at)googlemail(dot)com>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, "Peter Koczan" <pjkoczan(at)gmail(dot)com>, "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>, "pgsql-performance" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: disabling an index without deleting it?
Date: 2008-02-27 23:33:01
Message-ID: 12278.1204155181@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I wrote:
> In the particular case at hand, a planner hook to make it ignore the
> index is a far better solution anyway...

Just as proof of concept, a quick-and-dirty version of this is attached.
It works in 8.3 and up. Sample (after compiling the .so):

regression=# load '/home/tgl/pgsql/planignoreindex.so';
LOAD
regression=# explain select * from tenk1 where unique1 = 42;
QUERY PLAN
-----------------------------------------------------------------------------
Index Scan using tenk1_unique1 on tenk1 (cost=0.00..8.27 rows=1 width=244)
Index Cond: (unique1 = 42)
(2 rows)

regression=# set ignore_index TO 'tenk1_unique1';
SET
regression=# explain select * from tenk1 where unique1 = 42;
QUERY PLAN
---------------------------------------------------------
Seq Scan on tenk1 (cost=0.00..483.00 rows=1 width=244)
Filter: (unique1 = 42)
(2 rows)

regression=#

regards, tom lane

Attachment Content-Type Size
planignoreindex.c application/octet-stream 2.4 KB

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2008-02-27 23:37:44 Re: disabling an index without deleting it?
Previous Message Kevin Grittner 2008-02-27 23:18:50 Re: disabling an index without deleting it?