Is it possible to temporarily disable an index in Postgres?

后端 未结 3 1332
失恋的感觉
失恋的感觉 2021-01-30 03:57

I have got one index on a table that I would like to temporarily disable, I can\'t find any documentation suggesting that it\'s possible, though.

Reason: I\'ve got an in

3条回答
  •  萌比男神i
    2021-01-30 04:32

    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.

提交回复
热议问题