The query ran fast, but the table was wrong. The data needed a new column, and without it the system would fail.
Adding a new column is one of the most common schema changes in production databases. It is also one of the most dangerous if not done with intention. Poorly planned column additions can lock tables, block writes, and freeze entire applications. At scale, even a single ALTER TABLE can cascade into downtime.
The safest approach to creating a new column depends on the database engine. In PostgreSQL, adding a nullable column without a default is instant in recent versions. Adding a column with a default value rewrites the table and can be slow. MySQL’s behavior differs between versions, but large InnoDB tables can take seconds or minutes to lock during schema changes.
To avoid blocking, many teams now use online schema migration tools. These tools create a shadow table with the new column, keep it in sync via triggers or binlog streaming, and then swap it into place with minimal lock time. This strategy works for MySQL with tools like pt-online-schema-change or gh-ost, and for PostgreSQL using logical replication or application-layer dual writes.