Vector databases for RAG: pick for the job, not the hype
By Abdul Asim ·
What is a vector database?
A vector database stores embeddings, the lists of numbers a model produces to represent text or images, and finds the ones closest to a query embedding. In RAG, that lets you retrieve passages that mean the same thing as the question even when they share no words with it. Whether you need a dedicated one depends on your data volume, your query types and what you already run, and for many document systems the answer is no.
How vector search works in a RAG system
At ingest, each chunk of a document goes through an embedding model and is saved as a vector alongside its text and metadata. At query time, the question goes through the same model, and the database returns the nearest vectors by a distance measure such as cosine distance. Those chunks become the context the model answers from. The full request flow is in how a RAG pipeline works.
Comparing the query against every stored vector is exact, but it slows down as the collection grows. So most systems add an approximate nearest neighbour index. The most widely used is HNSW, a layered graph the search can hop through toward close neighbours instead of scanning everything. Approximate means you give up a little recall for a lot of speed. That trade is tunable, and you should measure it on your own questions rather than trust the defaults.
Three things affect answer quality more than the database brand: the embedding model, how the documents were chunked, and whether each vector carries metadata you can filter on, such as document type, version, date, owner or tenant.
Do you need a vector database for RAG?
Often not a separate one. A lot of document RAG starts small: a hundred or so contracts, specs, policies or past proposals, which becomes a few thousand chunks. At that size, an exact search over every vector is fast, and the real work is extraction, chunking and testing, not search speed. Three setups cover most projects:
| Setup | Good fit | Watch out for |
|---|---|---|
| In-process library, such as Faiss | Prototypes, small fixed corpora, batch jobs | No persistence, access control or live updates out of the box |
| Vector extension in the database you already run, such as pgvector for Postgres | Most document systems, data that already lives in SQL, joins with business records | Index tuning, and sharing resources with your transactional workload |
| Dedicated vector database, managed or self-hosted | Very large collections, heavy query volume, many tenants, a team that wants search as its own service | One more system to sync, secure, back up and pay for |
My default is the middle row. pgvector keeps vectors next to the rest of your data. Out of the box it searches exactly, with perfect recall, and it offers HNSW and IVFFlat indexes when you need approximate search. One database means one backup, one permission model and one place to join a retrieved chunk to the customer, contract or record it belongs to. That last part matters more than most comparison charts admit.
Move to a dedicated service when you can point to the reason: search load is slowing the main database, the collection has grown past what your indexes handle at acceptable recall, or several teams need to share one retrieval layer. Measure first. A migration you cannot justify with numbers is usually a migration you did not need.
When vector search was the wrong tool
The most useful selection lesson from my builds is that some questions should never reach vector search at all.
In the MavenIT quoting workflow, the system retrieves relevant historical quotes, but the price comes from defined pricing rules applied to structured equipment and contract data. Similarity is a fair way to find a comparable past quote. It is the wrong way to produce a number a customer will sign. When no suitable historical match exists, the case goes to a person for review, not to whichever neighbour happened to score highest.
In Permit Signal, vector search was one retriever out of four. Questions about places went to spatial lookup in PostGIS, exact identifiers to BM25 keyword retrieval, and counts and structured filters to SQL. If every question had gone through embeddings, a permit number or a street radius would have been matched by meaning, which is exactly what those queries cannot tolerate. That routing is covered in more depth in agentic RAG.
The rule I take from both: if the answer depends on an exact value, a calculation, a location or a business rule, use the system built for that. Use vector search for meaning.
Why hybrid search beats vector search alone
Embeddings handle paraphrase well and exact strings badly. Part numbers, permit IDs, SKUs, clause numbers and people's names get pulled toward neighbours that look similar and are wrong. Keyword ranking such as BM25 catches those reliably but misses paraphrase. Run both, merge the two result lists, and each covers the other's blind spot.
You do not need a special product for this. The pgvector README suggests pairing it with Postgres full-text search for hybrid retrieval and merging the lists with Reciprocal Rank Fusion or a cross-encoder. Add a reranker when the right chunks come back but in the wrong order. The components of a RAG pipeline shows where reranking sits relative to retrieval and generation.
Vector DB comparison: the criteria I actually use
When a dedicated option is justified, compare on what shows up in production, not on benchmark charts:
- Filtering during search. Can it restrict by tenant, date or document type while searching, not after? Filtering a top 10 after the fact can leave zero results.
- Hybrid support. Does it run keyword and vector retrieval together, or will you operate a second system?
- Updates and deletes. Documents change. How cheap is re-indexing one file, and does a deleted file drop out of results straight away?
- Re-embedding cost. Switching embedding models means re-embedding everything. Know how long that takes at your size.
- Access control and residency. Where does the data live, and can you enforce per-user permissions at query time?
- Operations. Backups, monitoring, upgrades, and who gets paged when it breaks.
- Cost at your real volume, not on the free tier.
If two options pass all of these, pick the one your team already knows how to run.
Mistakes that matter more than which database you pick
- Embedding queries and documents with different models or different preprocessing, so the two sides never line up.
- Chunks that cut tables or clauses in half, so no single vector holds the whole fact.
- No metadata, so you cannot filter by version or owner and outdated documents keep winning.
- Never measuring retrieval recall on real questions. Without a test set you cannot tell whether a database change helped.
- Treating the index as a one-off import instead of something that must stay in sync with its sources.
Each of these shows up later as one of the production RAG failures users notice first: a confident answer that ignores the document they know exists.
Key takeaways
- A vector database finds stored embeddings closest to a query, which lets RAG retrieve by meaning.
- For small and mid-sized document sets, a vector extension in your existing database is usually enough.
- Exact values, locations, calculations and business rules belong in SQL, keyword search, spatial lookup or code, not in similarity search.
- Hybrid retrieval with keyword and vector search covers identifiers and paraphrase together.
- Chunking, embeddings, metadata and evaluation decide answer quality far more than the database brand.
If you have a defined set of documents and want to know whether RAG can answer your users' questions before choosing infrastructure, my 100 Document RAG MVP takes up to 100 files and 20 to 25 of your real questions, builds cited answers on them, and reports what passed, what failed and why.
