The query runs, but the numbers don’t match. You scan the table again and realize the fix is simple: a new column.
Adding a new column in a production database is not trivial. Schema changes can lock writes, break dependencies, or trigger costly full table rewrites. The impact on performance, uptime, and downstream systems must be understood before making the change.
First, decide the column type. Choose the smallest data type that holds the needed values. This reduces storage costs and speeds queries. Avoid NULL defaults unless truly required; NULL-heavy columns complicate indexing and boolean logic.
Second, add columns in a way that avoids downtime. Many modern database engines support non-locking ALTER TABLE operations. Use ALTER TABLE ... ADD COLUMN with defaults applied in a separate step to prevent table rewrites. In systems without online DDL, consider creating a shadow table, backfilling data, and swapping in the new schema.