Flashcard: what is a vector database, and why does RAG need one?
A vector database is a data store built around fast approximate nearest neighbor search over high dimensional embeddings, so RAG can fetch the top-k similar chunks in milliseconds.
Imagine you have a library where every book is placed at a coordinate based on its meaning, so books about similar topics sit close together on a vast multi-dimensional shelf. Now someone walks in and asks a question. You convert their question into a coordinate too, and you need to find the books closest to that point. Walking past every shelf would take forever in a real library. So the library has a clever map that lets you jump straight to the right neighborhood without checking every aisle. A vector database is that library plus that map. It stores millions of vectors and ships with a search algorithm that finds the closest ones in milliseconds. Without it, RAG would crawl, because comparing one query against a million embeddings the slow way is a slow way.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: define the vector database as ANN index plus payload store, walk through why brute force scanning fails at scale, name HNSW and IVF, and list the 2026 vendor landscape.
Real products, models, and research that use this idea.
- Pinecone serverless hosting tens of billions of vectors with metadata filtering and sub-100ms search latency for production RAG.
- Qdrant running in single binary mode with HNSW and on-disk vectors, common in self-hosted enterprise RAG deployments.
- pgvector inside Postgres for teams that want vector search without operating a separate datastore, with HNSW added in pgvector 0.5+.
- Weaviate combining vector search with native BM25 keyword search for hybrid retrieval in customer support RAG products.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does HNSW achieve sub-linear search, and what parameters control the recall latency tradeoff?
QWhen would you pick pgvector over a dedicated vector database like Pinecone or Qdrant?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming a vector database is just a regular database with a vector column. The defining feature is the ANN index (HNSW, IVF, ScaNN) that makes top-k search sub-linear; without it you have storage, not retrieval.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.