The query ran fast, but the result was wrong. The data was fine—your schema was not. You forgot the new column.
Adding a new column in a database sounds simple, but the consequences ripple through queries, indexes, constraints, and downstream systems. Done right, it’s a clean extension. Done wrong, it causes lock contention, slow migrations, and app errors.
Schema design for a new column starts with a clear definition. Decide on the name, data type, default value, and nullability. Choose defaults carefully—adding a non-null column with a default can rewrite the entire table, locking rows for longer than you want in production. When in doubt, add the column as nullable first, backfill in batches, then enforce NOT NULL after data is in place.
Performance impact depends on the size of the table and the database engine. In PostgreSQL, ALTER TABLE ADD COLUMN is cheap if you allow NULLs and avoid large defaults. Avoid implicit casts during backfills. In MySQL, adding a column in the wrong place can trigger a full table rebuild; consider using ALGORITHM=INPLACE or INSTANT when possible.