Is it possible to temporarily disable an index in Postgres?

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. Note that I’ve only done a quick test to see if the index still seems to be updated, caveat emptor.

Leave a Comment