pg-blast-radius

Forecast what your PostgreSQL migration will block, for how long, on your actual workload.

$ pg-blast-radius analyse migration.sql --stats-file prod-stats.json

orders (34.0 GB, ~892M rows)
Lock: ACCESS EXCLUSIVE (blocks all reads and writes)
Duration: 16m (p50) 37m (p90) 37m (worst)
Blocked queries: 3 families, 14,202 calls/min combined
SELECT ... FROM orders WHERE customer_id = $1 8,100/min ~129,255 queued
INSERT INTO orders (...) 4,800/min ~76,596 queued
UPDATE orders SET status = $1 WHERE id = $2 1,302/min ~20,777 queued
Confidence: query load MEASURED, lock hold INFERRED

EXTREME ALTER COLUMN TYPE triggers table rewrite
Estimated: 6m (p50) / 12m (p90)

Rollout recipe: Expand/migrate/contract
1. [expand] ADD COLUMN "total_new" numeric
2. [backfill] UPDATE in batches
3. [switch] Application reads from new column
4. [contract] DROP old column, rename

Not a linter. Not a runner.

Linters tell you "this takes ACCESS EXCLUSIVE." pg-blast-radius tells you "this will queue 14,200 queries/min on your busiest table for 6..12 minutes."

It reads your migration SQL, connects read-only to your database, and produces workload-aware blast radius forecasts with explicit confidence accounting.

Blocked query forecast

Identifies which production queries from pg_stat_statements will be blocked, calculates queue depth per second, and ranks by impact.

Duration ranges

P50, P90, and worst-case estimates based on table size and observed transaction durations. Not single-point guesses.

Confidence ledger

Every forecast states what is known from PG docs, observed from catalog, inferred from workload, and what remains assumed.

Rollout recipes

Step-by-step safer SQL using expand/contract patterns. Each step tagged with its phase and lock impact.

Install

cargo install pg-blast-radius

Requires Rust 1.85+ and a C compiler for libpg_query. Read-only database connection for full analysis.

Three modes

Static (no database): lock modes, rewrite detection, rollout recipes. Confidence: STATIC.

Catalog-aware (table sizes): size-adjusted risk, P50/P90/worst duration forecasts. Confidence: ESTIMATED.

Workload-aware (pg_stat_statements + pg_stat_activity): blocked query families, queue depth estimates, lock acquisition delay. Confidence: MEASURED.