The query ran fast, but the table was wrong. It needed a new column.
Adding a new column is simple in principle, but the cost depends on the database, the data volume, and the operation type. In SQL, the core command is straightforward:
ALTER TABLE orders ADD COLUMN delivery_date TIMESTAMP;
This changes the schema immediately if the database supports metadata-only operations. Engines like PostgreSQL can add nullable columns without rewriting existing rows. But if you add a column with a default value or a NOT NULL constraint, it may trigger a full table rewrite, locking writes and consuming I/O.
In MySQL, an ALTER TABLE can be blocking on large datasets unless you use ONLINE DDL where supported. Some engines like ClickHouse treat a new column as a metadata change and fill values lazily, making the operation near-instant.