Try Bifrost Enterprise free for 14 days.
Request access
Back to Blog

Using pgvector with Bifrost: Semantic caching on the Postgres instance you already run

Vrinda Kohli

Dec 04, 2026 · 5 min read

Using pgvector with Bifrost: Semantic caching on the Postgres instance you already run

Bifrost's semantic cache can now keep its vectors in PostgreSQL, so you don't need to run a separate vector database.

Semantic caching saves you from paying twice for the same question. Users could ask "How do I reset my password?" and then "I forgot my password, how do I change it?", and Bifrost can answer the second one from the first response. It makes one small embedding call to match the question and skips the model call, so you don't pay for a second answer or wait for the model to write it.

But the cache needs to store its embeddings somewhere. Until now, a cache that every replica shares meant adding Weaviate, Qdrant, Redis or Pinecone. Many teams running Bifrost in production already run PostgreSQL for the config store and the logs store. Adding a second database just for vectors means another service to deploy, secure, back up, monitor and pay for.

With Bifrost v2.8.0, the semantic cache can now use pgvector as its vector store, in open source and Enterprise.

What this enables

  • Reuse what you have: Point the vector store at the database your logs store already uses, or at a separate one if you want to keep the load apart.
  • Keep your existing operations: Backups, point-in-time recovery, failover, access control and monitoring all apply to the vectors with no extra work.
  • Run it on managed Postgres: Amazon RDS, Cloud SQL, Azure Database for PostgreSQL and Supabase all ship pgvector.
  • Run it across replicas: very Bifrost replica reads and writes the same tables, so a cache entry written by one pod is a hit on every other pod.

The semantic cache plugin works as it does on every other backend, including thresholds, TTLs, per-model and per-provider scoping, and direct-only mode.

How pgvector works in Bifrost

pgvector can only index columns with a fixed dimension. Bifrost therefore gives each namespace its own table and records them in a vector_store_namespaces registry. Each table name is a hash of the namespace and its dimension, which keeps it under Postgres's 63-byte identifier limit. A namespace stays at the dimension it was created with, so to switch the cache to an embedding model of a different size, point it at a new vector_store_namespace.

The index depends on the size of your embeddings:

DimensionsIndexSearch
Up to 2,000HNSW on vector, cosineApproximate
2,001 to 4,000HNSW on a halfvec expressionApproximate, re-ranked at full precision
4,001 to 16,000NoneExact: no index, so every lookup scans the whole table

OpenAI's text-embedding-3-small (1,536 dimensions) falls in the first row, and text-embedding-3-large (3,072) in the second. Models in the halfvec range are searched in two stages. The index picks a few extra candidates, and Bifrost re-scores them at full precision before applying your threshold. Without that step, half precision can push a score of 0.79988 over a threshold of 0.8.

pgvector opens its own connection pool, so you can size it separately. On the same database, that pool (50 connections by default) adds to the config and logs stores' pools, so check the connection limit on a small instance. Its sessions show up in pg_stat_activity under an application_name ending in vectors.

Set it up

You need PostgreSQL with pgvector 0.8.0 or later, the first release with iterative index scans. To check what your database offers:

Then add a vector_store block to config.json. It takes the same connection settings as the logs store:

Then enable the semantic cache plugin as usual. To keep the vectors off the logs database, point host and db_name somewhere else and set max_open_conns to fit that instance. On RDS, you can use password_command to fetch IAM auth tokens instead of a static password.

For a quick local test:

On Kubernetes, the Helm chart's pgvector store defaults to the chart's own PostgreSQL. The bundledpostgres:16-alpine image doesn't include pgvector, so use the pgvector/pgvector image for new installs. If you already have a bundled install, don't swap its image with a plain helm upgrade: the two images sort text differently, so you need to rebuild indexes first. The Helm storage guide links to the migration steps.

Bifrost checks the extension before it starts

If something is wrong, Bifrost stops with the exact command to fix it rather than failing later on a query.

  • The extension isn't installed and Bifrost's user can't create it: a database administrator needs to run CREATE EXTENSION vector;.
  • The extension is older than 0.8.0: run ALTER EXTENSION vector UPDATE;. On managed Postgres, you may need to upgrade the engine's minor version first.
  • The extension is in a schema outside the user's search_path: the error names the schema and gives you an ALTER ROLE ... SET search_path command that keeps your current entries.

Replicas that start at the same time against an empty database coordinate through advisory locks, so a rolling deploy won't race to create the same table.

Get started

Upgrade to Bifrost v2.8.0 or later and point the vector store at the Postgres you already run. The pgvector integration docs cover the full configuration reference and production notes.