Vector Databases Retrieval Augmented Generation: How to Choose
Published:
Last Updated:
In a retrieval-augmented generation pipeline, a vector database stores your documents as lists of numbers and answers a question by finding the lists closest to the question’s own. The README for pgvector, the Postgres extension that does this job, spells out what happens when you also ask it to filter: with an approximate index, filtering is applied after the index is scanned, so a condition that matches 10% of rows returns about 4 results on average at the default hnsw.ef_search of 40. A user who asked for ten passages gets four. That is documented behavior, not a bug.
Most guidance ranks these products by speed and scale. Speed and scale rarely decide how a production system fails. Filters, tenant boundaries, and the question of whether a dedicated store is needed at all do.
The question is not which vector database is fastest. It is what each one does when a filter, a tenant boundary, or a permission check lands on top of the similarity search.
In Retrieval Augmented Generation, Approximate Nearest Neighbor Search Decides What the Vector Database Returns
A vector database stores vector embeddings, the numerical representations of text that a model produces, and returns the stored vectors nearest to a query embedding. That is how a RAG system performs semantic search: it ranks retrieved documents by semantic similarity to the user query instead of matching exact keywords.
The pattern predates the term’s popularity. The original RAG paper, Lewis et al. (2020), paired a pre-trained generator with a dense vector index of Wikipedia and reported more specific, diverse and factual generation than a parametric-only baseline. REALM, published three months earlier, put a learned retriever into language model pre-training instead. Both results are from 2020 and say nothing about today’s models. Retrieval raises the odds that an answer is grounded. It does not guarantee it, which is why the retrieval step and the generation step need separate metrics.
The retrieval augmented generation embedding step sets the terms for everything after it. The embedding model decides what “near” means, so stored vectors and query vectors must come from the same model. Voyage AI’s migration guide, hosted by MongoDB, is explicit that embeddings from different models aren’t comparable, and that the whole corpus has to be regenerated with the successor model even when the dimensions match. Because knowledge lives in the index, new data does not require retraining the model. Adding documents means embedding the new ones. Changing the model means embedding all of them again.
The search comes in two forms. By default, pgvector performs exact nearest neighbor search, which provides perfect recall. Adding an approximate nearest neighbor index trades recall for speed, and the README warns that queries return different results once one exists. HNSW, introduced by Malkov and Yashunin in 2016, is a multi-layer proximity graph whose authors report logarithmic complexity scaling. Speed is the benefit. A different result set is the price.
In RAG Systems, Filters Turn Approximate Search Into a Recall Problem, and Permissions Are Filters
The mechanism behind the opening example is simple. An approximate index returns a fixed number of candidates, and in pgvector the filter is applied to those candidates afterward. At the default hnsw.ef_search of 40, a filter matching 10% of rows leaves about 4. A filter matching 1% leaves fewer than one on average, by the same arithmetic.
Permission scopes are the most selective filters a RAG system applies. A user entitled to a small fraction of the corpus is routine wherever access is segregated by team or client, which describes most enterprise settings.
Stores handle this differently, and the differences are documented. pgvector added iterative index scans in 0.8.0, which keep scanning until enough results are found, up to a configured limit. Weaviate’s documentation describes pre-filtering: an allow-list of eligible objects is built first, ACORN is the default filter strategy since v1.34, and search can switch to brute force when a filter becomes restrictive enough, with a default cutoff of about 15% of the dataset. Weaviate also states that filtered recall is typically no worse than unfiltered recall. That is a vendor claim worth testing on your own data.
Qdrant’s documentation says filtering needs payload indexes on the fields you plan to filter on. Its 2019 design write-up on filterable HNSW explains why naive filtering during graph traversal fails past a threshold, because the graph decomposes into small connected components, and describes adding graph edges per category to keep it connected. The article says it covers the original design, not the current system.
None of this is exotic. All of it is invisible if the evaluation set ran without the filter. Recall measured on an unfiltered test set says nothing about recall under a permission scope, which is why How to Evaluate RAG Accuracy matters here: the extra step is running it under the filters production will apply.
The question is not whether the index is fast. It is whether it still returns ten results when the user can see one percent of the corpus.
Tenant Isolation Is a Storage Decision Before It Is a Prompt Rule
OWASP’s LLM08:2025 entry on vector and embedding weaknesses names the failure directly: in a multi-tenant setup, embeddings from one group can be retrieved in response to another group’s queries. Its recommendation is fine-grained access controls, permission-aware vector and embedding stores, and strict logical and access partitioning of datasets.
The isolation primitive varies by product. In a Pinecone retrieval augmented generation deployment it is the namespace: Pinecone’s documentation says to use one namespace per customer when you need to isolate data between customers. Weaviate gives each tenant a dedicated shard and a dedicated vector index. Qdrant recommends the opposite shape: one shared collection partitioned by a tenant field in the payload, because a collection per tenant is rarely the most efficient approach. Milvus documents four levels, database, collection, partition and partition key, and states the trade-off itself: stronger isolation costs scalability, and at the partition key level tenants can share a physical partition and RBAC is not supported.
Each is a statement about blast radius. A boundary enforced by the store fails closed. A tenant filter applied by the application fails open the first time someone omits it, and Qdrant’s own documentation notes that requests without the tenant filter are slower because they scan all groups, which means they still run.
Inside a tenant, per-document permissions remain filters, and everything in the previous section applies. RAG Security: Data Poisoning and Privacy Risks covers why permissions rarely survive chunking in the first place.
The Gateway Governs the Call, and the Store Governs the Document
Tenant boundaries and permission filters live in the store. The call that reaches the store is a separate layer, and since Obot is our platform, here is where it fits before the rest of the selection criteria. Obot is an Enterprise AI Control Plane built around three jobs: define what agents can reach, choose where they run, and prove what they did.
Gateway: Define What Agents Can Reach
When a vector store is exposed to agents as an MCP tool, two layers decide what a retrieval returns. Obot MCP Gateway is a centralized control plane that enforces fine-grained access control, integrates with existing identity providers (Okta and Microsoft Entra in the Enterprise edition), and maintains audit logs at the tool-call level. It governs who can invoke the retrieval tool and records each call, in the shape described in what to log when an agent calls a tool and tool-level permissions. Building Agentic RAG with MCP shows the pattern end to end.
Device: Watch and Enforce With Obot Sentry
A gateway only governs retrieval that routes through it. A developer can point a local MCP server at a vector store from Claude Code or Cursor, using a connection string with full read access and no tenant filter at all. Obot Sentry scans AI client configurations on developer machines, including Claude Code, Claude Desktop, Codex, Cursor, and VS Code, reports which MCP servers, skills, and plugins each one loads, and can block servers that aren’t approved.
Hosted: Claude Environments
Obot v0.27 added Claude Environments, hosted Claude Code environments that run under the same control plane, so an agent’s retrieval connections come from policy rather than a local config file.
It does not replace what the store does. Tenant isolation, document-level filters and recall under those filters live in the vector database, and they need the testing described above. Governance at the gateway is an infrastructure-level guarantee. Governance inside each retrieval server is a bet. Neither substitutes for the other.
The gateway is built for organizations that need enterprise governance without routing sensitive agent traffic through third-party infrastructure. That is the same logic the embeddings section below applies: where the vectors live and who can call them are one question, asked twice.
A Dedicated Vector Database Is Optional, and Hybrid Search Is a Feature, Not a Product
Three facts complicate the assumption that RAG needs a separate store. pgvector turns Postgres into a vector store with exact search as its default. Amazon S3 Vectors, generally available since December 2, 2025, supports up to two billion vectors per index and returns frequent queries in around 100 milliseconds or less, and AWS claims up to 90% lower total cost to upload, store and query vectors. And the retrieval-quality evidence that exists does not favor vector-only search: Anthropic’s 2024 Contextual Retrieval results, summarized in Retrieval Augmented Generation Trends 2026, moved top-20 retrieval failure from 3.7% to 2.9% by adding lexical BM25 to contextual embeddings.
Vector search also comes in several shapes, and treating them as one category is how comparisons go wrong. FAISS is a library: its README describes it as a library for efficient similarity search and clustering of dense vectors, and nothing in the part read for this article covers filtering or running as a service. pgvector is an extension that adds the capability to Postgres. Pinecone, Qdrant, Weaviate, Milvus and Chroma are databases and services built for it, and Amazon S3 Vectors adds it to object storage. The deployment model says more about operational burden than the product name does.
Hybrid search is a feature set, not a product category. Embeddings rank on meaning, while the keyword search a traditional search engine runs ranks on exact terms, and Anthropic’s Contextual Retrieval results show BM25 added to embeddings cutting failed retrievals further on its own datasets. Qdrant’s Query API fuses results with reciprocal rank fusion or distribution-based score fusion, and Weaviate fuses BM25F keyword results with vector results, using relative score fusion as its default since v1.24.
What follows is a set of decision criteria, not a verdict. Corpus size, filter selectivity, latency target and who operates the system each move the answer. A managed service reduces operational work, not decisions: filter behavior, tenant model and testing stay with you, and “zero operational overhead” is marketing. Exact search has perfect recall by definition. Whether it is fast enough depends on the corpus and the latency target, and only a test on your data can answer that.
The dedicated database is a choice. It is not a prerequisite.
Your Own Data Lives in the Embeddings, So Where They Live Is a Governance Decision
A vector store is a copy of the corpus in transformed form, not an index over it. Morris et al. showed that a multi-step method can recover 92% of 32-token text inputs exactly from their dense embeddings, and that it recovered full names from a dataset of clinical notes. Embeddings can leak much of the text they were built from.
That makes managed versus self-hosted a data governance decision, not a convenience trade-off. A May 2025 post on the Veeam community forum made the argument as one practitioner’s opinion: managed vector database services require sharing data with a third party, so the author self-hosts. It is an opinion, not evidence, but it names the question correctly.
In regulated industries, the question becomes a compliance one, because the store holds material derived from regulated documents, and that derivation can be partly reversed. The decision belongs with the people accountable for proprietary data, not whoever picks the cheapest tier.
cheapest tier.
Choosing the Right Vector Database Means Checking Key Features Against Documentation, Not a Ranking
For a comparison of the best vector databases for retrieval-augmented generation in 2025 and 2026, no neutral benchmark turned up, so the table below ranks nothing. It records what each product’s documentation commits to on the three questions above, and only what was read for this article. “Not verified” is not a negative finding.
Comparison matrix
Store
Filtered search
Tenant isolation
Hybrid search
pgvector
Filter applied after an approximate index scan; iterative scans since 0.8.0
Not verified
Not verified
Pinecone
Metadata filter limits the search; unfiltered queries search the whole namespace
Namespace per customer
Not verified
Qdrant
Payload indexes needed for performant filtering; filterable HNSW design from 2019
Shared collection, tenant field in payload
RRF and DBSF fusion through the Query API
Weaviate
Pre-filtering with an allow-list; ACORN default since v1.34; flat-search cutoff about 15% by default
Dedicated shard per tenant
BM25F plus vector, relative score fusion default since v1.24
Milvus
Not verified
Database, collection, partition or partition key level; RBAC at the first two only
Not verified
Chroma
A where metadata filter on query and get
Not verified
The metadata filtering page does not describe hybrid search
Judge a store on three measures: retrieval quality under your filters, latency at your corpus size, and total cost. Documentation answers none of them. Milvus’s own multi-tenancy page says search performance depends on indexes, parameters and hardware, and recommends testing before choosing a strategy. Two more criteria do not fit a table. The update path matters because query and stored embeddings must come from the same model, so a model change means regenerating the corpus. And data location, covered above, is a property of how you deploy, not of the product. Choosing a vector database is less about which one searches fastest and more about three behaviors you can test before you commit: what the index returns under your filters, where the tenant boundary is enforced, and where the vectors physically live. A product that cannot answer all three from its documentation has not answered the question. Speed is a benchmark result. Recall under a permission filter is a requirement.
FAQs
What is a vector database in RAG?
A vector database in RAG stores embeddings of your documents and returns the vectors nearest to a query embedding, so the language model receives passages that match the meaning of the question. It also stores metadata, such as source or owner, that queries can filter on. It is the retrieval layer of a RAG pipeline, not the model.
How does Obot help with a vector database for RAG?
When the vector store is exposed as an MCP tool, Obot MCP Gateway controls which agents and users can call it and logs every retrieval call, and Obot Sentry finds retrieval servers developers configure locally. Tenant isolation and document-level filters still have to be enforced in the vector database itself.
What does RAG stand for and how does it work?
RAG stands for retrieval augmented generation. A system retrieves relevant passages from an external knowledge base at query time, ranked by semantic similarity, and passes them to the model as context, so answers draw on proprietary data instead of training data alone. Updating the index does not require retraining the model.
Do I need a vector database for retrieval augmented generation?
Not necessarily. pgvector provides exact nearest neighbor search inside Postgres, and Amazon S3 Vectors is a managed alternative documented for up to two billion vectors per index. Whether a separate store is justified depends on corpus size, filter selectivity, latency target and who operates the system.
What is the difference between a vector database and a regular database for RAG?
A query carries a condition on stored metadata, such as a tenant or document owner, along with the query vector. How the condition meets the index differs by product: pgvector applies it after an approximate scan, Weaviate builds an allow-list first, and Qdrant relies on payload indexes. Test recall under the filters your users will actually have.
What is HNSW and why do vector databases use it?
HNSW, Hierarchical Navigable Small World, is a graph-based method for approximate nearest neighbor search, described in a 2016 paper by Malkov and Yashunin. It builds layered proximity graphs so a search can move from coarse to fine neighbors instead of comparing against every vector. Databases use it because it is fast, at the cost of exact recall.
How do you keep a vector database up to date?
Adding or changing documents means embedding the new content and upserting it. Changing the embedding model is different: embeddings from different models aren’t comparable, so the corpus has to be regenerated. Plan for the second case before choosing a model.
Is a retrieval-augmented generation vector database secure enough for private data?
Not by default. OWASP’s LLM08:2025 recommends permission-aware stores and strict partitioning of datasets, and published research shows that embeddings can leak much of the text they were built from. Tenant isolation, access control at the tool layer and the choice between managed and self-hosted deployment all need an explicit decision.RAG stands for retrieval augmented generation. A system retrieves relevant passages from an external knowledge base at query time, ranked by semantic similarity, and passes them to the model as context, so answers draw on proprietary data instead of training data alone. Updating the index does not require retraining the model.
How do I choose the best vector database for RAG?
There is no single best. Test filtered recall on your own data, check how each product enforces tenant isolation, confirm hybrid fusion if keyword matching matters, and decide where the vectors will live. The choice that survives those four checks is the right one for your system.