When you add a new column to a database table, you change the shape of the data. The operation can be instant on small datasets, or it can lock a table for hours in production. The difference comes down to size, engine, and migration strategy.
Most relational databases—PostgreSQL, MySQL, and others—store table metadata alongside the data itself. Adding a nullable new column with no default is often fast because it updates only the schema. Adding a column with a default value, or making it non-nullable, usually requires rewriting the entire table on disk. That’s where downtime happens.
In PostgreSQL, ALTER TABLE ADD COLUMN is the command. For large tables, use a default of NULL first, then update the data in batches. Only after the backfill is complete should you set constraints or defaults. This minimizes locks and reduces impact on queries.
In MySQL and MariaDB, online DDL features can make adding a new column more efficient, but you must check your storage engine. InnoDB supports most operations without full table locks, but older engines do not. Always test in a staging environment with production-like data volumes.