The database was fast, but the schema was not built for what came next. You needed a new column.
Adding a new column should be simple, yet it can break production, slow queries, and lock tables. The way you create, populate, and index that column determines whether your migration runs in seconds or stalls for hours.
In relational databases like PostgreSQL, MySQL, and MariaDB, ALTER TABLE ADD COLUMN is the basic syntax. By default, this is an instantaneous metadata change if no default value is written to every row. Adding a default with NOT NULL can cause a full table rewrite, blocking reads and writes until it completes. To avoid downtime, first add the column as nullable without a default, then backfill in batches, and finally enforce constraints.
For production databases under high load, online schema change tools like pt-online-schema-change or gh-ost allow you to add new columns without locking the main table. Cloud-managed databases may handle small changes instantly, but large alterations still require careful execution.