Adding a new column sounds simple. It is not. The decision touches schema design, query patterns, storage, and performance. One wrong choice can cause migrations to stall, indexes to bloat, or even break production code.
A new column in a relational database means altering the table definition. In PostgreSQL, you can use:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This command is atomic, but on large datasets the operation can lock the table. For high-traffic systems, plan for zero-downtime schema changes. Tools like pg_repack and strategies like creating the column nullable, then backfilling in batches, can keep your service healthy during deployment.
Name the column with precision. It must be clear, consistent, and aligned with existing naming patterns. Types matter: choosing a smaller type like SMALLINT if values will never exceed its limit saves space and improves cache efficiency. Default values can simplify application logic, but be cautious; setting defaults on large tables can slow migrations if not handled carefully.