The data was good, but the table needed a new column.
Adding a new column is not just a schema change. It can alter performance, impact application logic, and affect every downstream system that touches the data. Whether you are using PostgreSQL, MySQL, or a cloud data warehouse, the right approach will depend on your constraints, your deployment environment, and your tolerance for downtime.
First, define the column’s purpose and type. Use the most precise data type possible. Smaller, fixed-width types improve performance and reduce storage costs. Avoid nullable columns unless the data model requires them. For default values, set them explicitly to prevent inconsistent inserts.
In PostgreSQL, adding a column without a default is O(1) and nearly instant. But adding a default value rewrites the entire table, which can lock and slow queries. In MySQL, the operation can be blocking unless you use ALGORITHM=INPLACE or a tool like pt-online-schema-change. In distributed and cloud databases, consult your provider’s documentation, as adding a new column may cause a full table rebuild under the hood.