Schema migrationsadvancedPro runbook

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.

ProCaptured evidence where the run produced it

Full runbook for this incident

The scenario above is free. What Pro unlocks is the fix: how to identify change a column type without a full table rewrite, the exact SQL to trace it, PostgreSQL 18 output for the steps we captured, the resolution path, and how to stop it recurring.
  • 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.

Compare plans

ShareLinkedInX

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.

FollowSubstackLinkedInnew errors · lab notes · hiring loops