The query ran. The table was large. You needed a new column.
Adding a new column sounds simple, but in real systems the wrong approach can lock tables, break queries, and cost hours of downtime. Done right, it’s instant, safe, and doesn’t slow your production database. Done wrong, it’s a migration nightmare you won’t forget.
A new column in SQL means altering the table schema. The key variables: database size, index strategy, default values, and concurrent writes. For small datasets, ALTER TABLE ADD COLUMN works. On massive tables with millions of rows, the database must update metadata and sometimes rewrite every row to store the new attribute. That’s where the pain starts.
Best practice is to add columns without defaults when possible, letting application logic fill values over time. Avoid schema changes in peak traffic windows. In PostgreSQL, adding a nullable column is fast — just a metadata update. Adding with a non-null default prior to v11 rewrote the table entirely. MySQL’s performance depends on the storage engine version; InnoDB can be fast for certain column types but will still lock if done naïvely.