Adding a new column sounds simple. In production, it’s not. The decision touches schema, indexes, query plans, replication lag, and application code. A careless change risks downtime or data corruption.
When adding a new column, start with the schema definition. Choose the correct data type. Plan for nullability, default values, and constraints. Avoid setting defaults that force a table-wide rewrite on large datasets.
For relational databases like PostgreSQL and MySQL, run DDL changes in a way that minimizes locks. On PostgreSQL, consider ALTER TABLE ... ADD COLUMN with no default and update rows in batches. For MySQL, use tools like gh-ost or pt-online-schema-change to apply the migration without blocking writes.
Test the new column in staging with production-sized data. Check the performance impact on queries, especially if you plan to add an index immediately. Index creation can cause blocking or large spikes in I/O. Add indexes separately when possible.