The query ran fast and failed. The cause: the table needed a new column.
Adding a new column sounds simple. It is not. The wrong approach locks the table, blocks writes, and stalls production. The right approach depends on database type, table size, and uptime needs.
In PostgreSQL, ALTER TABLE ADD COLUMN is instant when adding a nullable column with no default. A column with a default value before version 11 rewrites the table. That can take hours for large datasets. After version 11, adding a default uses the metadata path and is far faster.
In MySQL, ALTER TABLE often copies the entire table, leading to downtime. Use ALGORITHM=INPLACE where possible, or online schema change tools like gh-ost or pt-online-schema-change for zero-downtime migrations.