Creating a new column sounds simple. It isn’t, if you care about uptime, data integrity, and performance. Schema changes can lock tables, slow queries, and hurt deployments. The key is planning and execution.
First, understand the database engine’s behavior. In PostgreSQL, adding a column with a default value rewrites the entire table, which can cause downtime. Without a default, the column is added instantly, and you can backfill data in smaller batches. In MySQL, depending on the storage engine and version, some column adds are online; others require table-copy operations.
Second, handle type selection with care. Using the smallest type that fits your data improves storage and speed. Booleans, enums, and fixed-length integers are faster to scan than wide text fields. Always consider nullability—nullable columns can be slower to filter and join, but safer for rolling deployments.