Change a column type without a full table rewrite
Some type changes rewrite the whole table; others do not. Watch the relation's filenode: varchar to text keeps the same filenode (no rewrite), while int to bigint gets a new one (full rewrite).
Problem
What you're actually looking at
The symptom as it shows up on a real server.
ALTER COLUMN ... TYPE can be free or catastrophic. If the on-disk representation is unchanged (or binary-coercible), PostgreSQL skips the rewrite; if it changes, the whole table is rewritten under an exclusive lock. The relation's filenode tells you which happened.
Meridian plans two type changes on tracking_codes and wants to know which will rewrite the table. Comparing the filenode before and after each change answers it definitively.
Simple terms
Changing a column's type can be nearly free or genuinely dangerous, and the two look identical in the SQL. If the new type is stored the same way on disk, varchar to text, for instance, PostgreSQL skips the rewrite. If the storage changes, like int to bigint, it rewrites the entire table under an exclusive lock. You can tell which happened by watching the table's on-disk file id (its filenode): a new filenode means it rewrote everything.
Full runbook for this incident
- The full identify checklist, the exact signals that tell you it's this incident
- Every diagnostic query; lab output is attached only to the steps we actually captured
- The resolution path and the pitfalls that make it worse
- Mitigation steps to stop it recurring, plus a verify-you're-done query
Card required. Cancel before day 7 and you are not charged.
More in this category
Other Schema migrations runbooks
Neighbouring incidents that share the same diagnostic surface.
Connected
How this connects to the rest of the library
A live view of this page's real cross-references, what explains it, what fixes it, what to tune, and where to go next. Every link is an authored relationship, not a guess.
Need the full procedure?
Pro runbooks finish the incident path
Free runbooks teach the shape. Pro opens the full step transcript, edge cases, and prevention depth.