Advanced INT to BIGINT Conversions
summary
Postgres integer overflow hits around 2.1 billion and causes sudden outages; recommended quick fix is ALTER SEQUENCE to restart at a negative min (buying ~2 billion inserts) and then plan a migration to BIGINT. Practical migration uses a new BIGINT column, view+triggers to route reads/writes, batched backfill, and transactional DDL for fast metadata swaps. Also use a catalog+pg_stats query to locate INT columns, test with a default-function that injects high IDs, and watch for ORM bugs (e.g. Django sequence mismatch) and unsigned-int or client-side limits. ALTER SEQUENCE negative restart view + fut_y BIGINT + backfill
AI-written summary · about
chapters (5)
- 0:00Introduction
- 1:45SMALLINT, BIGINT, INTEGER
- 5:25Avoiding the 'INTEGER' problem
- 13:45Dealing with overflows in production
- 19:57Other problems to consider








