The database was slowing down, and the query plan told the truth. The missing piece was clear: you needed a new column.
Adding a new column is one of the most common schema changes, but it can also be one of the most disruptive. On large datasets, a careless operation locks tables, stalls writes, and turns deploys into incidents. Understanding both the syntax and the impact is critical.
In SQL, the basic command is simple:
ALTER TABLE orders ADD COLUMN status VARCHAR(20);
But the real work is in choosing the right data type, setting defaults, and deciding whether to allow NULL values. Every choice affects indexing, storage, and long-term performance. Adding a new column to a production table with millions of rows can trigger a full table rewrite. That rewrite can block other operations for minutes or hours if not done carefully.
Plan the migration in steps. First, add the new column without defaults or constraints. This is often a metadata-only change in modern databases like PostgreSQL or MySQL on the right version. Then backfill in batches to avoid massive lock contention. Only after the data is filled should you add NOT NULL constraints or indexes.