Why Model Deprecations & Upgrades Cause Outages
Google’s legacy textembedding-gecko and text-embedding-004 retirement schedules and OpenAI’s legacy text-embedding-ada-002 (~61.0 MTEB, $0.10/1M) leave millions of production tables pinned to aging vector spaces. Because every embedding model learns an arbitrary orthogonal rotation of its latent hypersphere, even two 1,536d models have zero geometric compatibility ($\mathbb{E}[q_{\text{v2}} \cdot d_{\text{v1}}] \approx 0$).
Worse, running UPDATE chunks SET embedding = $1 across 10,000,000 PostgreSQL MVCC rows duplicates every wide text row on disk (2x+ WAL + dead-tuple bloat).
Five-Phase Zero-Downtime Sidecar Cutover Pattern
| Migration Phase | Read Path (SELECT) |
Write Path (INSERT/UPDATE) |
Backfill & Index State | Rollback Time |
|---|---|---|---|---|
| 1. Sidecar DDL | v1 table + v1 HNSW |
v1 only |
Create narrow chunk_embeddings_v2 (chunk_id PK, emb halfvec) |
Instant (0 ms) |
| 2. Dual-Write | v1 table + v1 HNSW |
Write v1 + async v2 |
Live edits stay 100% synced in v2 |
Instant (0 ms) |
| 3. Keyset Backfill | v1 table + v1 HNSW |
Dual-write | Stream WHERE NOT EXISTS in 5,000-ID keyset pages (no index yet!) |
Instant (0 ms) |
| 4. Build HNSW + Shadow Diff | v1 primary + 5% async v2 diff |
Dual-write | CREATE INDEX CONCURRENTLY on v2 (maintenance_work_mem='32GB') |
Feature flag (< 1s) |
5. Cutover & Drop v1 |
v2 HNSW 100% |
v2 only (after 48h soak) |
DROP TABLE chunk_embeddings_v1 (0 VACUUM bloat!) |
Feature flag during 48h soak |
Runnable SQL + Python Keyset Backfill & One-Line Forge Cutover
1. Zero-Bloat PostgreSQL Sidecar Schema
-- Narrow sidecar table avoids MVCC full-row rewrite bloat on your 10M-row main chunks table
CREATE TABLE chunk_embeddings_v2 (
chunk_id BIGINT PRIMARY KEY REFERENCES doc_chunks(id) ON DELETE CASCADE,
model_rev TEXT NOT NULL DEFAULT 'forge-pro-2560',
embedding halfvec(2560) NOT NULL
);
-- Wait until keyset backfill reaches 100% BEFORE building HNSW (3x faster bulk graph build!):
-- SET LOCAL maintenance_work_mem = '32GB';
-- CREATE INDEX CONCURRENTLY idx_emb_v2_hnsw ON chunk_embeddings_v2 USING hnsw (embedding halfvec_cosine_ops);
2. Idempotent Keyset Backfill Worker (base_url = "https://api.voxell.ai/v1")
import os
from openai import OpenAI
import psycopg
# 1-line SDK swap from OpenAI to Voxell Forge (Turbo 1024d is $0 forever; Pro is 2560d)
forge = OpenAI(
base_url="https://api.voxell.ai/v1",
api_key=os.environ["FORGE_API_KEY"],
)
def backfill_sidecar(dsn: str, batch_size: int = 256) -> None:
last_id = 0
with psycopg.connect(dsn) as conn:
while True:
rows = conn.execute(
"""
SELECT c.id, c.body
FROM doc_chunks c
LEFT JOIN chunk_embeddings_v2 v2 ON v2.chunk_id = c.id
WHERE c.id > %s AND v2.chunk_id IS NULL
ORDER BY c.id ASC
LIMIT %s
""",
(last_id, batch_size),
).fetchall()
if not rows:
break
ids = [r[0] for r in rows]
texts = [r[1] for r in rows]
resp = forge.embeddings.create(model="pro", input=texts)
with conn.cursor() as cur:
cur.executemany(
"""
INSERT INTO chunk_embeddings_v2 (chunk_id, embedding)
VALUES (%s, %s)
ON CONFLICT (chunk_id) DO NOTHING
""",
[(cid, item.embedding) for cid, item in zip(ids, resp.data)],
)
conn.commit()
last_id = ids[-1]
Benchmark Before You Backfill (Zero API Key)
Before re-embedding 10M chunks, verify recall improvement on your hardest failing queries with a zero-key bake-off against Voxell Forge (C_corpus Stage-1 99.04% Recall@20 + Max Stage-2 0.8849 nDCG@10):
curl -sS -X POST https://api.voxell.ai/api/v1/agent/bakeoff \
-H "Content-Type: application/json" \
-d '{
"documents": [
{"name": "migration-mvcc.md", "text": "Backfilling embeddings into a narrow sidecar table avoids PostgreSQL MVCC dead-tuple bloat on wide text tables."},
{"name": "migration-turbo.md", "text": "Voxell Forge Turbo 1024d costs $0 per 1M tokens forever, eliminating token fees during 10M-vector backfills."}
],
"queries": ["How do you avoid PostgreSQL MVCC dead-tuple bloat when re-embedding 10M rows?"]
}'
Calculate your exact backfill cost ($0 on Turbo, $0.25/1M on Pro) in the Vector RAM & TCO Calculator, review the OpenAI 3-large Migration Guide, or open the Forge Console (v4.0 Pricing).