November 5, 2025
Index drama: drop it like it’s hot
Moving tables across PostgreSQL instances
Postgres table move sparks a hot tip: drop indexes or suffer
TLDR: The article explains how to move specific Postgres tables using logical replication: copy data first, then add constraints and indexes. The standout community tip is to drop destination indexes before copying, or the migration crawls—making this speed hack the must-know move for anyone shuffling data between servers.
A programmer wanted to move just a few tables between two PostgreSQL servers—not the whole database—and found Google’s DMS won’t do table-by-table. Cue the switch to logical replication: first an initial bulk copy, then real-time change tracking. The guide’s big twist? Create tables without constraints and indexes, add primary keys, copy the data, then rebuild the rest. The community latched onto one theme with near-religious fervor: indexes are the slowdown villains. User fourseventy, mid-upgrade from Postgres 15 to 18, dropped the mic with a warning that if you keep indexes during the copy, every single insert has to update them and the whole job crawls. The mood was equal parts relief and war stories: you could practically hear ops folks muttering “drop first, rebuild later.” People nodded at the advice to handle functions and enums manually and keep primary keys ready, because the change-tracking relies on them. No flame wars here—just a shared trauma over progress bars stuck at 99% and the collective wisdom that patience plus a clean schema save the day. In short: flexible table-only moves are possible, but the community’s mantra is clear—ditch those indexes, then go fast.
Key Points
- •Google Cloud’s DMS migrates entire databases and doesn’t support table-level moves, leading to the use of PostgreSQL logical replication.
- •Replication access must be granted to user accounts on both source and destination (e.g., REPLICATION role in Cloud SQL).
- •Schemas should be copied first; use pg_dump with --section=pre-data to export table definitions without constraints or indexes.
- •Logical replication runs an initial dump then CDC; constraints like foreign keys can’t be enforced during initial dump, so defer them.
- •Primary keys are required for logical replication and should be restored separately; functions and enums may need manual handling.