The query finished running, and the table felt wrong. The schema was missing something. You needed a new column—and you needed it fast.
Adding a new column can be simple, but a careless change can lock rows, block writes, or slow the entire system. The right approach depends on your database, your workload, and your tolerance for downtime. In PostgreSQL, ALTER TABLE ADD COLUMN adds a column instantly if no default value is set. Add a default, and it can rewrite the whole table. In MySQL, adding a nullable column without a default is fast for InnoDB, but adding a column with constraints can trigger table copy operations.
For production systems, small details decide success. Test the schema change in a staging environment with real data volume. Monitor query plans before and after adding the new column. Create indexes only after backfilling values, unless you want long lock times. Break large migrations into steps: