The query runs, but the numbers make no sense. You realize the schema is wrong. You need a new column.
Adding a new column to a database table is simple, but the impact is never small. It can change queries, indexes, and performance. It can break code in production if you do not plan it. The right process keeps systems stable while evolving the schema.
Create the new column in a way that avoids full table locks on large datasets. In PostgreSQL, use ALTER TABLE ... ADD COLUMN with defaults applied in a separate statement to reduce write amplification. In MySQL, check the storage engine and row format before altering to avoid downtime. For distributed databases, ensure schema changes propagate cleanly to replicas.
If the new column is nullable, adding it is often fast. But default values, constraints, and triggers add complexity. Populate the column in controlled batches to avoid overloading the database. Add the necessary indexes only after the column is filled and queries confirm the need. Indexing too early can slow bulk updates.