Re: disabling an index without deleting it?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: binFcb5wPTgqp.bin
Description: planignoreindex.c

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux