The query finished running, but the table was wrong. The numbers were off. You scroll back through the code and see the missing piece: a new column.
Adding a new column should be fast and predictable. In SQL, ALTER TABLE is the starting point. Whether you use PostgreSQL, MySQL, or SQLite, the core syntax is straightforward:
ALTER TABLE orders
ADD COLUMN processed_at TIMESTAMP;
This creates the column at the end of the table definition. Most relational databases will write-lock the table during the operation. On large datasets, that can block reads and writes for seconds or even minutes. If uptime matters, schedule the migration during low-traffic windows or use online schema change tools.
A new column in PostgreSQL defaults to NULL unless you specify a DEFAULT value. Adding a default and a NOT NULL constraint will trigger a full table rewrite, which multiplies the operation’s cost. In MySQL, the rules differ; some defaults can be applied instantly. Always check your database’s migration documentation before production changes.