Disable an index in postgres

If you have got one index on a table that you would like to temporarily disable you can do following steps.

You can poke the system catalogue to disable an index:

update pg_index set indisvalid = false where indexrelid = 'test_pkey'::regclass

This means that the index won’t be used for queries but will still be updated. It’s one of the flags used for concurrent index building.

If you want to run a single query without using index, you can use following query.

drop index mytable_index;

explain analyze select * from mytable;

I don’t think there is a way to disable just one, though you can do this in a transaction to make recovering from it very simple. You can also disable indexscan to disable all indices.

Reference : http://stackoverflow.com/questions/6146024/is-it-possible-to-temporarily-disable-an-index-in-postgres