The query was slow. The schema was wrong. You knew it the moment you saw the execution plan. A new column was the fix. Simple in theory. Dangerous if you get it wrong in production.
Adding a new column means more than modifying a table. It changes storage, alters indexes, shifts query performance, and can trigger locks. In large datasets, the wrong alter can freeze writes for minutes or hours. That’s downtime you can’t buy back.
Before you add a new column in PostgreSQL, MySQL, or any modern SQL database, check the table size. If it’s terabytes, avoid a blocking operation. Use ALTER TABLE ... ADD COLUMN with care. Consider default values. A static default can rewrite every row, which can be costly. If possible, add the column nullable, then backfill in batches.
In PostgreSQL, adding a nullable column without a default is fast; it updates only the metadata. Adding with a default rewrites disk pages. In MySQL, the effect depends on the storage engine and version. For InnoDB, avoid full table rebuilds unless required.