embedsync
Keep pgvector search current as PostgreSQL rows change, without losing or duplicating a single update.
$ embedsync search "how do I entertain my indoor cat"generation minilm embed 11.8ms query 2.1ms 1. [2] 0.705 Keeping an indoor cat happy 2. [3] 0.100 Sourdough basics$ embedsync verifyboundary 0/16BF970 checkpoint 0/16BF970source_state: missing=0 extra=0 stale=0minilm: expected=2 actual=2 missing=0 stale=0ok=trueThe problem
Embeddings go stale the moment the row behind them changes. Cron re-embeds and trigger queues leave search wrong for seconds to minutes, and a crash between “embedded” and “recorded” can lose or repeat work.
postgres-embedding-sync follows a table through logical replication, re-embeds only the chunks that changed, and writes the vectors to pgvector in the same transaction as its replication checkpoint. It measures how long a commit takes to become searchable and switches embedding models blue/green while serving searches.
What it does
- Vectors, the dead-letter queue and the replication position commit in one transaction, so a kill -9 at any point neither loses nor duplicates an effect.
- Per-chunk fingerprints over text, transform and model revision: unchanged chunks are skipped and obsolete ones removed.
- Watermark backfill runs in the same stream as live changes, and deletes are never resurrected.
- Blue/green model migration gated on coverage, catch-up and retrieval quality, with atomic promotion and a rollback window.
- verify compares every source row with every sink chunk at one replication boundary: ok, differences or error, and nothing in between.
- Vector, full-text and hybrid search with typed metadata filters and tenant scope. A local CPU embedder with pinned model revisions, or OpenAI-compatible and Gemini endpoints.
How it works
- 1
An explicit publication with a column list feeds a logical replication slot, so only the key and allowlisted columns ever leave the source. Whole transactions are read.
- 2
Each change becomes chunks with deterministic IDs and fingerprints. The embed stage batches, rate-limits and retries, and rows the embedder rejects are quarantined in a versioned dead-letter queue.
- 3
Effects, DLQ records, progress and the end LSN commit as one sink transaction. Standby feedback reports only that durable position, so the slot never moves ahead of what is safely stored.
Decisions worth noting
Unknown is never ok
verify has three answers with distinct exit codes. If the check can't reach a consistent boundary, it reports an error, never a pass.
A worse model doesn't ship
A candidate generation must pass paired-bootstrap non-inferiority gates on nDCG@10 and recall@10 before promotion. On BEIR SciFact, MiniLM → bge-small was promoted (+0.073 nDCG@10) and a smaller model was rejected while bge kept serving.
More views
