Vector Database
What is it?
A vector database stores embeddings and finds the items most similar to a query by comparing their vectors, enabling fast meaning-based search.
Explain like I'm 5
Why was it created?
Comparing millions of embeddings one by one is too slow. Vector databases were built to search huge collections of vectors quickly.
Where is it used?
- Semantic search
- Retrieval-augmented generation (RAG)
- Recommendations
- Finding similar images or documents
Why should developers care?
They're the storage layer behind semantic search and RAG, so anyone building AI features over their own data uses one.
How does it work?
You store each item's embedding vector. At query time, the database compares the query's vector against stored ones using approximate nearest-neighbor search, returning the closest matches very fast.
Real-world example
A support assistant embeds the company's docs into a vector database; each user question retrieves the most relevant passages to feed the model.
Common use cases
- RAG retrieval
- Semantic and similarity search
- Recommendation engines
- Deduplication and clustering
Advantages
- Fast similarity search at scale
- Built for embeddings
- Powers RAG and semantic search
- Approximate search keeps it quick
Disadvantages
- Another system to operate
- Approximate results aren't always exact
- Quality depends on the embedding model
- Costs grow with data size
When should you use it?
When you need fast similarity search over many embeddings.
When should you avoid it?
For small datasets, where a simple in-memory search or a regular database may suffice.
Alternatives
Related terms
Interview questions
Beginner
- What does a vector database store?
- What is it used for?
Intermediate
- What is nearest-neighbor search?
- Why is search approximate?
Senior
- How does a vector database support RAG at scale?
- What trade-offs come with approximate nearest-neighbor indexes?
Common misconceptions
- "A vector database replaces your regular database" — it complements it, handling similarity search, not general data storage.
- "Results are always exact" — most use approximate search for speed.
Fun facts
- They rely on approximate nearest-neighbor algorithms to stay fast at scale.
- Some traditional databases now add vector search as a feature.
Timeline
- 2020s — Vector databases surge alongside RAG and LLM apps
Learning resources
Quick summary
A vector database stores embeddings and quickly finds the most similar ones, powering semantic search and the retrieval step in RAG.
Cheat sheet
- Stores and searches embeddings
- Finds nearest vectors fast
- Approximate nearest-neighbor search
- Backbone of RAG retrieval