Making large Postgres migrations practical: 1TB in 2 hours with PeerDB
PeerDB migrated a 1TB, 3.6-billion-row Postgres table in about 1 hour 50 minutes with 8 threads, compared with 8 hours 40 minutes for native logical replication and 17 hours for pg_dump/pg_restore. The speedup comes from parallel snapshotting. A consistent snapshot is exported via pg_export_snapshot, the table is split into CTID ranges, and each range is streamed with binary COPY, with per-partition retries and progress visibility. Past a certain level of parallelism the source RDS network bandwidth becomes the limit, so 16 threads were no faster than 8 at 1TB. For CDC, PeerDB keeps the replication slot consumed independently of destination writes. It also reconstructs unchanged TOAST columns from batch caches and MERGE against the target, so REPLICA IDENTITY FULL is not needed.
Related posts
- How we migrate TBs from Heroku without logical replication
PlanetScale mediumAdeptPlanetScale's open-source Heroku Migrator moves multi-terabyte Postgres databases off Heroku standard plans, which lack WAL access and logical replication, by using Bucardo trigger-based replication: triggers record changes in delta tables, a one-time COPY loads existing data, and a worker replays the backlog before a controlled switchover with verification. Version 2.0 fixes failures seen on large migrations. Bucardo's single-transaction initial copy restarted from zero after any interruption, so the migrator now drops secondary indexes before the copy and rebuilds them in parallel afterwards, raising throughput from about 60 to nearly 300 GB/h. It also disables transaction_timeout on Bucardo's connections, sets TCP keepalives so silently dropped long-lived connections fail within about a minute, and tunes host TCP buffers. A discovery CLI and the Liftoff assessment flag tables without primary keys, incompatible extensions and sizing before the migration starts.
- The growing pains of database architecture
Figma mediumAdept
Facing ~3x annual database traffic growth and 65% peak CPU on a single Amazon RDS Postgres instance, Figma chose vertical partitioning (moving groups of tables to their own databases) over horizontal sharding, NewSQL, or self-hosting. Candidate tables were picked by measuring average active sessions from pg_stat_activity sampling and by tracing ActiveRecord queries into Snowflake to find isolated table groups. Migration used logical replication, with destination indexes dropped and rebuilt to cut initial copy from weeks to hours. Cutover went through a two-phase PgBouncer split, a brief pause with query cancellation, LSN-based sync checks, and reverse replication for rollback, keeping availability impact under a minute.
- How we migrated Clera’s 500 GB production database to ClickHouse Managed Postgres overnight
ClickHouse mediumAdept
Clera moved a 500 GB, 500+ table production Postgres database from the EU to the US overnight onto ClickHouse Managed Postgres, with production traffic still running, using two parallel ClickPipes pipelines. The vendor choice followed a replay of their real workload (hot reads, point lookups, background analytics) on Supabase, Neon, PlanetScale and ClickHouse, plus sysbench TPC-C at 8–128 threads. Local NVMe storage beat network-attached storage, with 16–42% higher TPS than PlanetScale out of the box, and CPU fell from days at 100% to 10–20%. The hard parts were extension portability, restoring triggers, rebuilding indexes, resequencing tables, and doing parity checks before cutover.
- Postgres on NVMe: performance and the convergence of transactions and analytics
ClickHouse mediumAdept
Running Postgres on local NVMe instead of gp3 EBS gave 9.2× more throughput (16,030 vs 1,734 TPS) and UPDATE latency of 4.0 ms vs 36.9 ms in a pgbench benchmark with a 482 GiB dataset about 30× larger than RAM. Profiling showed EBS backends spending 89% of wall time blocked on I/O. VACUUM ran 2.6× faster on NVMe, while logical decoding gained only 1.7× because it is single-threaded. To offset NVMe's ephemerality, durability moves into Postgres via quorum synchronous replication across AZs plus continuous WAL archival to S3 with WAL-G. Analytics still needs a columnar engine, so the recommended pattern is CDC (PeerDB, or the new WalShadow) into ClickHouse, queried through the pg_clickhouse extension.
- I Dropped a Table in Production—Now What?
Neon mediumAdept
Neon's instant point-in-time recovery creates a new copy-on-write branch at a moment just before a dropped table. That branch is available in about one second regardless of database size, and production keeps running while it is created. Two recovery routes follow from this. One is to pg_dump the table out of the recovered branch and import it into production, which keeps all data written after the drop. The other is to use Branch Restore to swap production onto the recovered branch under the same connection string, which discards post-drop writes. RDS, by contrast, restores a snapshot to a new instance and replays WAL, which can take hours for multi-terabyte databases.