Postgres: Dropping a column with index drops the index on all other columns(dba.stackexchange.com)
dba.stackexchange.com
Postgres: Dropping a column with index drops the index on all other columns
https://dba.stackexchange.com/questions/251838/prevent-drop-column-with-index-on-it-in-postgresql
2 comments
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.
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.
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!