The query ran fast, but the schema had changed. You needed a new column, and the clock was already ticking.
Adding a new column to a database should be simple. In practice, it can cause downtime, locks, or migration delays if done carelessly. Whether you are working with PostgreSQL, MySQL, or a distributed system, the goal is the same: introduce the column without slowing production or breaking queries.
First, decide if the new column requires a default value or not-null constraint. Adding these at creation time can lock the table. Many engineers add the column as nullable, then backfill data in batches, and finally set constraints in a second step. This staged approach prevents performance hits and keeps writes flowing.
Second, check all read and write paths. Application code must handle both the absence and presence of the new column during deploys. Feature flags or conditional logic ensure compatibility across rolling releases.