The fix began with a new column.
Adding a new column to a production database is not just an ALTER TABLE command. It’s a decision that affects performance, storage, and code paths. A single DDL change can lock tables, block writes, and spike CPU. Planning matters.
First, choose the correct data type. Keep it as small as possible to reduce storage and index overhead. Avoid NULL defaults unless they are meaningful—explicit defaults make migrations safer and queries faster.
Second, decide how to backfill. In large datasets, backfilling in a single transaction can create long locks. Use staged migrations. Add the new column, deploy code that can handle NULL or default values, and populate the data in controlled batches.