The query was slow. The logs showed nothing. Then you saw it—the table needed a new column.
Adding a new column sounds simple. In production, it can be dangerous. Schema changes that lock a table can halt writes, stall reads, and trigger cascading timeouts. Even a single ALTER TABLE ADD COLUMN can degrade performance if it’s done without planning.
Before adding a new column, identify its purpose. Is it for a feature flag, analytics, or critical domain data? Determine its type, constraints, nullability, and default values. Defaults that require rewriting all existing rows can be costly at scale. Use database-native tools to add non-blocking defaults, or backfill in controlled batches.
Choose the right migration strategy. For small tables, a direct DDL change may be fine. For large tables, add the column as nullable first. Deploy code that can handle both old and new schemas. Backfill data asynchronously. Once complete, enforce constraints. This minimizes downtime and risk.