Infrastructure

Vector databases for RAG: what actually matters

Vector databases are the least interesting decision in RAG — and the one teams spend the most time on. For most systems, any competent option works. The differences that matter are filtering, hybrid support, and operational fit.

First: do you need one?

Under ~100,000 chunks, an in-process index (FAISS, NumPy, or a simple inverted index) is often enough. A dedicated vector database adds operational surface you may not need.

You need one when you have:

  • Millions of vectors
  • Multi-tenant access control
  • Frequent updates and deletes
  • Metadata filtering at scale
  • Multiple services querying concurrently

The options

OptionStrengthWatch out for
pgvectorOne database; SQL joins; transactionalANN performance at very large scale
QdrantStrong filtering; payload indexes; self-hostableExtra service to operate
WeaviateHybrid built in; schema-richMore opinionated; heavier
PineconeManaged; low opsCost; vendor lock-in
FAISSFast; embeddable; freeNo persistence, filtering, or auth

Filtering is the real differentiator

In document RAG you almost always filter before or during search: by tenant, document type, date, section, or access-control list.

Pre-filtering that isn't supported efficiently forces you to over-retrieve and post-filter, which destroys recall and leaks information.

# Pre-filter: only documents this user may see, of the right type
results = index.search(
    vector=query_vector,
    filter={"tenant_id": user.tenant, "type": "policy"},
    limit=50,
)

Hybrid support

Some databases support BM25 or sparse vectors natively; others require a separate lexical index. Either is fine — but know which you're building. See hybrid search.

Operations

  • Backups: can you restore the index and metadata together?
  • Re-indexing: how long to re-embed the corpus after a model change?
  • Deletes: do deleted documents actually disappear from results?
  • Multi-tenancy: is isolation enforced in the query path?
  • Observability: can you see query latency and recall per tenant?

A sane default

If you're already on Postgres, start with pgvector. You get transactions, joins, backups, and one fewer service to run. Move to a dedicated engine when you hit a measured limit, not a hypothetical one.

Rule: choose the database that makes filtering and re-indexing easiest. ANN speed is rarely your bottleneck; retrieval quality is.

Choosing infrastructure for a document RAG system?

I'll help you avoid over-engineering and pick the smallest stack that meets your scale and access-control needs.

Book a diagnostic