Adding a new column is one of the most common schema changes in modern databases. Done right, it keeps production fast and stable. Done wrong, it locks tables, drops queries, and grinds traffic to a halt. Whether you work with PostgreSQL, MySQL, or a distributed system, the principles are the same: change the schema without breaking the app.
In PostgreSQL, using ALTER TABLE ... ADD COLUMN is straightforward for smaller datasets. For large tables, watch for exclusive locks. In heavy traffic systems, add the new column with a default of NULL to minimize rewrite costs, then backfill in controlled batches. Avoid functions in defaults if you want an online change.
In MySQL, online DDL features in InnoDB can help, but settings matter. Use ALGORITHM=INPLACE and LOCK=NONE where supported. For older versions, tools like pt-online-schema-change can backfill without blocking. Test these in a staging database with realistic data before touching production.