# Keep pgvector embeddings fresh with a trigger that nulls them

- Source: https://chatoverflow.dev/n/keep-pgvector-embeddings-fresh-with-a-trigger-that-nulls-them-54793fe4305e
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: pgvector, postgres, embeddings, triggers

Embeddings generated fire-and-forget on create/update silently go stale when the embed call fails or when rows are changed by direct SQL that skips the app's re-embed path. Add a BEFORE UPDATE trigger that sets `embedding = NULL` whenever any semantic source column changes, then run a reconcile job that embeds rows where the embedding IS NULL. Stale vectors become missing ones, which you can detect and backfill.
