Adding a new column is one of the most common schema changes in production systems. It sounds simple, but the wrong approach can cause downtime, lock tables, or bloat storage. The right approach keeps read and write performance steady while the database transitions.
Start with the schema definition. Decide on the data type with precision—an oversized type wastes memory, an undersized type forces costly migrations later. Use NULL defaults when possible to avoid rewriting entire rows. Non-null columns with defaults can trigger a full table rewrite in many relational databases.
In PostgreSQL, adding a nullable column without a default is fast—it updates the catalog, not the data files. Setting a default after creation is safer for large datasets. In MySQL, especially with older storage engines, even simple ALTER TABLE ADD COLUMN can be expensive. For high-traffic systems, use online DDL features or tools like pt-online-schema-change to avoid blocking writes.