Zenaique

Order the migration steps for moving 8M vectors from Pinecone to pgvector with zero query downtime.

Order steps·Medium·4.0 · 0·~1 min·Asked atCredFreshworksH2o Ai
Attempt it
  • 1After a stable soak period, stop dual writes and decommission the Pinecone index
  • 2Bulk export historical vectors plus metadata from Pinecone and COPY them into Postgres, then build the HNSW index
  • 3Shift read traffic to Postgres gradually behind a flag, watching error rates and tail latency
  • 4Shadow query both systems with mirrored production traffic and compare recall, latency, and result overlap
  • 5Enable dual writes so every new upsert and delete is applied to both Pinecone and Postgres
  • 6Provision Postgres with pgvector, create the table, choose the distance operator, and plan HNSW parameters to match production recall needs
TL;DR

Provision pgvector, start dual writes, bulk-export and build the HNSW index, shadow-compare, flip reads behind a flag, soak, then decommission Pinecone.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Moving 8 million vectors from one database to another while the application keeps running is like changing a tire on a moving car. You cannot stop, and you cannot lose any spinning rubber. The trick is to bolt on the new tire next to the old one, drive on both for a while so they share the load, prove the new one handles the road the same way as the old one, then slowly shift weight onto it. Only after the new tire has carried full weight on its own for a few days do you actually remove the old one. Every step in this sequence exists to keep the car driving smoothly even if you discover the new tire is the wrong size halfway through.

Key concepts

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Pinecone-to-pgvector migrations have become common as teams consolidate operational surface area, reduce vendor cost, or align retrieval with their relational data. The migration mechanics are well understood at this point: it is fundamentally a zero-downtime data migration with the added wrinkle that the new system has different index-building semantics and the old system is a managed service with API rate limits on bulk operations.

This deep-dive walks through the six-step sequence in detail, the rollback invariant that forces the order, the parameter-tuning required to make pgvector match Pinecone on retrieval quality, and the operational subtleties (Postgres vacuum, index bloat, replication) that surface only after the soak period starts.

Provisioning pgvector correctly

Distance operator alignment

Pinecone exposes cosine, dot product, and Euclidean metrics. pgvector exposes three operator classes for HNSW: vector_cosine_ops, vector_ip_ops (inner product), and vector_l2_ops (Euclidean). The choice must match the source database exactly. A migration that switches metric silently rebuilds the entire ranking and the migration becomes a quality regression.

The operator is fixed at index creation time. Changing it requires dropping and rebuilding the index.

HNSW parameters

pgvector HNSW takes two build-time parameters: m (max connections per node, typically 16-32) and ef_construction (search width during build, typically 64-200). Higher values give better recall at the cost of build time and index size. For an 8M-row corpus at 768-1536 dim, sensible defaults are m=16, ef_construction=100. For workloads that need very high recall, push to m=24, ef_construction=200.

Query-time recall is also gated by ef_search, a session parameter. Default is 40; production deployments typically run 80-200.

Capacity planning

An 8M-row HNSW index at 1536 dim float32 with m=16 is roughly 50 GB on disk (raw vectors) plus 5-15 GB graph overhead. The Postgres instance needs shared_buffers and work_mem sized accordingly, plus enough RAM beyond that for the index pages to stay hot. Skimping on RAM is the most common reason pgvector underperforms Pinecone in benchmarks.

Dual writes and the bulk load
Shadow comparison and the read flip
Decommissioning and the operational reality of pgvector
The 2026 Pinecone-to-pgvector migration checklist with numbers
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Supabase has documented Pinecone-to-pgvector migrations for cost-driven moves; their template follows the dual-write plus bulk-load shape.
  • Neon and Crunchy Data publish similar migration playbooks for managed Postgres with pgvector targeting Pinecone customers.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow do you tune `ef_search` to match Pinecone recall without blowing the latency budget?
A

Sweep ef_search across {40, 80, 120, 200} on a labelled probe set; pick the smallest value that meets the recall target. Watch p99 latency at each setting because ef_search is linear in cost. Document the chosen value for ops; default 40 is rarely enough.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Starting the bulk export before dual writes are live, which leaves Postgres missing every upsert that landed during the export window.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Why dual writes must precede the bulk export

  • Distance-operator alignment as a correctness prerequisite

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
HNSW vs IVF, when…
Flashcard·Medium