The table was large. The solution was simple: add a new column.
A new column changes how your data flows. It can speed up lookups, simplify joins, and cut query costs. But adding one is never just about schema. It’s about understanding impact, locking strategies, migrations, and how the database serves production traffic while evolving.
When you create a new column, start with the schema definition. In SQL, use ALTER TABLE with precision. Always define the data type, default values, and constraints explicitly. Avoid nulls unless they have a clear reason to exist. The database engine will rewrite storage or metadata; know which applies to your system. Postgres can add certain columns instantly, but others trigger a full table rewrite. MySQL may block writes during the change unless you enable online DDL.
Backfill is often the hidden cost of a new column. Filling it with existing data can tax disk and CPU. For large tables, batch updates in small chunks prevent transaction bloat. Use indexing rules carefully — new indexes speed queries but slow writes. Only add them if the column will be filtered or joined often.