The query ran fast, but the schema stayed still. You needed a new column.
Adding a new column to a database table changes how your data lives, moves, and scales. The process must be deliberate. Schema changes in production can block writes, lock tables, or cause downtime if handled without care.
First, define the new column with precision. Pick the correct data type. Consider nullable versus non-nullable. If the column will be indexed, think about how that affects existing query plans. Every decision affects performance.
For relational databases like PostgreSQL or MySQL, use ALTER TABLE to add the new column. On large tables, a direct ALTER TABLE ... ADD COLUMN can be disruptive. Online schema change tools—such as gh-ost or pt-online-schema-change—allow you to add columns without locking writes.
In cloud environments, check for limits on schema changes and how they interact with replicas. For distributed databases, a new column may propagate across shards or regions, introducing replication lag.