The schema was breaking. The query timed out. The fix was simple: add a new column.
A new column changes everything. It alters the shape of your data, the way your indexes work, and the speed of your queries. Done right, it’s a quick migration. Done wrong, it’s a production outage.
When you create a new column in SQL, choose the right data type from the start. Use VARCHAR for strings, avoid TEXT unless required. Pick BIGINT over INT when future growth demands it. Define defaults to prevent null chaos. Always set constraints to preserve data integrity.
In PostgreSQL, adding a new column is straightforward:
ALTER TABLE users ADD COLUMN last_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
This command is small but has impact. It writes a new definition to your table schema. On large datasets, it can lock the table. Plan for maintenance windows or use ADD COLUMN with NOT NULL plus a default in newer versions for faster writes.