What is a Vector Database?
If you’ve ever used a search engine, a recommendation system, or a chatbot that “remembers” things - you’ve interacted with the technology that vector databases power. This page explains what vector databases are, why they’re essential for AI, and how they differ from traditional databases you may already know.The problem with traditional databases
Traditional databases - like PostgreSQL or MySQL - store data in rows and columns. They are extremely good at answering questions like:- “Give me all users where
age > 25” - “Find the product with
id = 42” - “Show me all orders placed after January 1st”
- “Find me documents that are semantically similar to this paragraph”
- “Which of these 10 million songs sounds like this one?”
- “What memories does this AI agent have that are relevant to this conversation?”
What is a vector?
Before understanding a vector database, you need to understand what a vector is in this context. A vector is simply a list of numbers. For example:What does a vector database do?
A vector database is a system optimized specifically for storing and searching vectors. It does three things: 1. Stores vectors alongside their metadata (the original text, image, document, etc.) 2. Builds an index - a specialized data structure that makes searching through millions of vectors fast. Without an index, you’d have to compare your query vector against every stored vector one by one. With a good index like HNSW, you can find the nearest neighbors in milliseconds. 3. Returns nearest neighbors - given a query vector, it returns thek most similar vectors in the database, ranked by similarity score.
A concrete example
Imagine you’re building a customer support chatbot. You have 50,000 support tickets from the past 5 years. Without a vector database:- User asks: “My payment keeps failing at checkout”
- You do a keyword search for “payment” and “checkout”
- You find tickets that contain those exact words
- You miss tickets that say “card declined” or “transaction error” - same problem, different words
- You embed each support ticket into a vector using an embedding model
- User asks: “My payment keeps failing at checkout”
- You embed the question into a vector
- You query the vector database for the 5 most similar tickets
- You get back tickets about “card declined”, “transaction error”, “payment gateway issue” - all semantically relevant even though the words are different
- Your chatbot answers using those relevant tickets as context
How does vector search work?
At its core, vector search is about measuring distance between vectors. Two vectors are “similar” if the distance between them is small. There are three common distance metrics: Cosine similarity - measures the angle between two vectors. Ignores magnitude, only cares about direction. Best for text and most NLP tasks. Euclidean distance - measures the straight-line distance between two points in space. Good for image embeddings. Dot product - measures the product of two vectors. Fast to compute, used in some recommendation systems. VecLabs supports all three. For most use cases involving text and language models, cosine similarity is the right choice.Approximate vs Exact search
Finding the mathematically exact nearest neighbor in a large vector space is expensive. For most AI applications, you don’t need the exact nearest neighbor - you need vectors that are close enough. Approximate Nearest Neighbor (ANN) search trades a tiny amount of accuracy for a massive gain in speed. VecLabs uses the HNSW algorithm for ANN search, which delivers recall rates above 95% while returning results in under 5ms even at 100K+ vectors. For a deeper explanation of how HNSW works, see The HNSW Algorithm.Vector databases vs traditional databases
| Traditional DB | Vector DB | |
|---|---|---|
| Query type | Exact match, range | Semantic similarity |
| Data type | Structured rows/columns | High-dimensional vectors |
| Index type | B-tree, hash | HNSW, IVF, LSH |
| Use case | Transactions, reporting | AI search, recommendations, memory |
| Query speed | Microseconds | Milliseconds |
| Scales to | Billions of rows | Hundreds of millions of vectors |
What can you build with a vector database?
- AI agent memory - store everything an agent learns and retrieve relevant memories at query time
- RAG pipelines - give LLMs access to your private knowledge base at inference time
- Semantic search - search by meaning, not keywords
- Recommendation systems - find items similar to what a user has interacted with
- Duplicate detection - find near-duplicate documents, images, or records
- Anomaly detection - find vectors that are far from everything else
Next steps
How Embeddings Work
Learn how text, images, and other data gets converted into vectors.
The HNSW Algorithm
Understand the index structure that makes fast vector search possible.