We had a column that we wanted to make nullable and so we ran the following migration:
ALTER TABLE example_table ALTER COLUMN example_column DROP NOT NULL;
Unexpectedly, this took a long time to run and resulted in downtime for our web service. We've been scratching our heads about why. This table is frequently scanned but never written, and it has a unique index on example_column.
Why did this cause a drop in performance?
Our best theory is that the unique index was dropped in Postgres internals behind-the-scenes and then rebuilt, but there's nothing in any documentation I've read that indicates that would happen for this kind of column interaction.
Why did this A) take a long time, and B) wreck performance?