The migration was supposed to be simple. One new column, a small schema change, and no downtime. By midnight, the logs told a different story.
Adding a new column is never just about altering a table. It’s about understanding the data model, the queries it powers, and the performance tradeoffs that can turn a change into a bottleneck. In many production systems, schema changes can block reads, lock writes, or ripple through replication lag.
The first question is scope. Will this new column store nullable values at first, or will it require a default? Adding a column with a default and a NOT NULL constraint can rewrite the entire table. On large datasets, that’s an expensive operation. Nullable columns generally add faster, but they push complexity to the application layer, where missing values need safe handling.
Next comes indexing. Resist the reflex to index the new column immediately. Test first. A low-cardinality index is costly in storage and often useless for query planning. Adding indexes ties up disk, I/O, and CPU time during creation, sometimes slowing or blocking transactions.