top | item 40818613

(no title)

bugfactory | 1 year ago

What else would you have expected? You can't index what's not there. It makes sense that DROP COLUMN would also cascade to DROP INDEXes.

The author of the question writes:

> If you overlook such situation, you can get serious problems in production.

Really? I hope you think it through before you DROP COLUMN in production!

discuss

order

eurleif|1 year ago

It's not entirely out of the question that dropping column `b` could convert an index on `(a, b)` into an index on just `a`. An index on `(a, b)` can be used to optimize queries on just `a`, and you might have created the index to accommodate queries on either `a` or `(a, b)`, so this behavior would change query optimization less than dropping the index.

I'm not arguing this would be correct behavior. It would probably be too magical. But it does make some sense why someone might expect this behavior.