The query finished running, but the data isn’t enough. You need a new column. You need it now.
Adding a new column is one of the most common schema changes, yet it can still break production if handled poorly. Whether you are using PostgreSQL, MySQL, or a distributed database, the process must balance speed, safety, and minimal downtime.
In PostgreSQL, ALTER TABLE ADD COLUMN is simple but not always cheap. Adding a column with a default value can lock the table and rewrite every row. For large tables, this can block writes for minutes or hours. The safer approach is to add the column without a default, then backfill data in batches. Once populated, set the default for new rows.
MySQL behaves differently. Adding a column may trigger a full table copy depending on storage engine and MySQL version. Online DDL (ALTER TABLE ... ALGORITHM=INPLACE) can help, but you must test in a staging environment with production-like data. Even so, long-running transactions can delay schema changes, so coordinate changes tightly.