Effect of deleting index while table is being use in postgresql

All we need is an easy explanation of the problem, so here it is.

What is the effect of removing or deleting a index while the table is being use?

sample:


from


table: order_tbl
index: order_id_index(not btree)

to


need to change it to
index:order_id_index(btree)


is there an impact or data lost while/after delete the index?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

You cannot drop an index while the table is being used, because dropping an index requires a (short) ACCESS EXCLUSIVE lock on the table, which conflicts with any concurrent access.

No data get lost when you drop an index, but the performance of queries could suffer drastically. If the new index is a replacement for the old one, you could create the new index with a different name, drop the old index and then rename the new index.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply