Skip to content
Preptima
hardScenarioDesignSeniorStaffLead

You need to migrate the schema of a 400-million-row table on a live system. Talk me through the plan, the backup you would want first, and how the connection pool affects it.

7 min readUpdated 2026-08-15

Answer

Short answer

Every step is chosen to hold weak locks briefly - add the constraint invalid and validate separately, index concurrently, backfill in committed batches - behind a restore you have rehearsed and timed, and a pool small enough that one blocked DDL statement does not exhaust it.

Was this answer helpful?

Likely follow-ups

  • Which of your steps needs a lock that blocks reads, and for how long?
  • Your backfill is causing replication lag. What do you change?
  • How do you make the application deployable both before and after the migration?
  • PgBouncer is in transaction pooling mode. Which application features stop working?

Related questions

Further reading