The query returned fast, but the table lacked what you needed. It was time to add a new column.
In every database, schema changes are inevitable. Business logic evolves. Data models expand. Requirements shift. The simplest and most common schema change is adding a new column to an existing table. Yet it’s also a change that can impact performance, uptime, and code stability if handled carelessly.
A new column can store flags, track states, record metrics, or link related data. How you define it matters. Choosing the right data type is critical. A BOOLEAN field takes less space than an INT. A VARCHAR(255) can be too large when a VARCHAR(50) is enough. The default value affects backfill costs and migration time. NULL vs. NOT NULL changes how queries behave and what constraints you must enforce.
In SQL, the statement is simple:
ALTER TABLE orders ADD COLUMN status VARCHAR(20) NOT NULL DEFAULT 'pending';
But production systems are more complex. Large tables take time to rewrite. Adding a new column with a default to millions of rows can lock the table for minutes or hours. This may block writes or degrade reads.