What Is a Vector Database? How It Works and Why RAG Needs It
A vector database stores embeddings and finds data by meaning, not exact words. See how it works step by step, why it is the heart of RAG, and which tools are popular.

What Is a Vector Database?
A normal search looks for matching words. A vector database looks for matching meaning.
Ask “How can I reset my password?” and a vector database can find a document titled “Steps to recover your forgotten login credentials”, even though almost no words are shared.
Formally, a vector database is a database built to store, index and search vector embeddings efficiently. Embeddings are lists of numbers that capture the meaning of text, images, audio or documents.
How Does It Work?
There are two stages.
1. Indexing your data (done once)
Documents → Split into chunks → Embedding model → Vectors + metadata stored in the vector database
2. Answering a query (every time)
Question → Embedding model → Query vector → Similarity search → Most relevant chunks
The database compares the query vector with the stored vectors and returns the closest ones. Common ways to measure “closeness” are:
Cosine similarity: compares the direction of two vectors
Euclidean distance: the straight-line distance between them
Dot product: combines direction and size
Why Is It Important for RAG?
In a RAG (Retrieval-Augmented Generation) system, the vector database is the searchable knowledge layer.
Documents → Chunks → Embeddings → Vector database → Similarity search → Relevant context → LLM → Answer
Imagine a company assistant with 100,000 HR documents. A user asks, “How many days of annual leave do employees get?” Sending all 100,000 documents to the LLM is impossible. Instead, the vector database finds the three or four most relevant policy pages, and only those go to the model.
This helps the system:
Search large document collections quickly
Ground the LLM's answer in real documents
Keep the context small, which lowers cost and latency
Work with private or domain-specific knowledge without retraining
Popular Vector Databases
Pinecone
Weaviate
Milvus
Qdrant
Chroma (handy for local experiments)
pgvector, which adds vector search to PostgreSQL
Vector Database vs Traditional Database
Traditional database | Vector database |
|---|---|
Optimised for structured rows and exact queries | Optimised for similarity search on embeddings |
“Find rows where status = active” | “Find text that means something similar” |
Keyword or rule-based matching | Meaning-based (semantic) matching |
Many real systems use both: vector search for meaning plus normal filters (date, category, user) on metadata.
Interview Tip
Don't say “A vector database is just a database that stores vectors.” A stronger answer:
“A vector database is optimised for storing and retrieving high-dimensional embeddings by similarity, which makes it the retrieval layer in systems like RAG and semantic search.”
Key Takeaway
Vector database = store + index + similarity search for embeddings. In RAG, it finds the right information before the model writes a single word.
Want to build this yourself? You will store embeddings, run similarity search and feed the results to an LLM. Start the free course AI Engineering with LLMs: Beginner.
Related articles
More in AI Fundamentals
What Is Similarity Search? How Does Cosine Similarity Work in AI?
Similarity Search helps AI systems find information that is semantically similar to a query. Learn how embeddings, vector databases, and Cosine Similarity work together in modern AI applications.
2 min readAug 28, 2026What Is an AI Agent? How Is It Different From a Chatbot?
A chatbot answers. An AI agent works toward a goal: it plans, calls tools, checks results and acts. See the difference with real examples, the building blocks, and the risks.
3 min readAug 20, 2026AI Model vs AI API vs AI Application: What’s the Difference?
An AI model, an AI API, and an AI application are different layers of an AI system. Understanding how they work together is essential for building real-world AI applications.
2 min readAug 19, 2026Zero-Shot vs One-Shot vs Few-Shot Prompting: What's the Difference?
The difference is simply how many examples you put in the prompt: none, one, or a few. See each with a ready-to-copy example, when to use which, and the token trade-off.
2 min readAug 19, 2026What Is Semantic Search? How Is It Different from Keyword Search?
Semantic Search finds information based on meaning and context rather than exact keywords. Learn how embeddings and vector search make modern AI-powered search more intelligent.
2 min readAug 19, 2026
What Are Embeddings in AI? How Do They Work?
Embeddings turn text, images and other data into lists of numbers that capture meaning, so similar ideas end up close together. Learn how they work and where they power RAG and search.
3 min readAug 17, 2026
Comments
Sign in to join the discussion.


