What Is a Vector Database? β Definition and How It Works
Learn what a vector database is, how approximate nearest-neighbour search works, how it differs from a relational database, and when you need one.
A vector database stores embeddings and answers one question quickly: which stored items are closest to this one? That question is the retrieval step behind semantic search and RAG.
1. What Is a Vector Database?
A vector database is a store built around similarity search rather than exact matching.
- Key idea: the primary access pattern is "nearest neighbours of this vector", not "rows where column equals value".
- Mechanism: an index structure that avoids comparing the query against every stored vector.
- Goal: millisecond similarity search over millions of items, with metadata filtering alongside.
Example of a Record
{
"id": "doc-4192#3",
"vector": [0.021, -0.114, 0.087, "..."],
"text": "Residential proxies route requests through consumer ISP addresses.",
"metadata": { "source": "guide", "section": "proxies", "updated": "2026-05-02" }
}
The text is stored alongside the vector because retrieval must return something a language model can read.
2. Why Exact Search Does Not Scale
Comparing a query against every vector is exact but linear: a million vectors of a thousand dimensions is a billion multiplications per query. Vector databases trade a small amount of accuracy for a large amount of speed using approximate nearest-neighbour indexes.
| Index family | How it narrows the search | Trade-off |
|---|---|---|
| Graph-based | Walks a navigable graph toward closer neighbours | Fast and accurate; higher memory use |
| Cluster-based | Searches only the nearest clusters | Compact; misses neighbours near cluster edges |
| Quantisation | Compresses vectors into approximate codes | Very small; loses fine-grained precision |
"Approximate" means a small share of true nearest neighbours can be missed. Tuning that recall against latency is the main operational knob.
3. How It Differs From a Relational Database
| Aspect | Relational database | Vector database |
|---|---|---|
| Query | Exact predicates and joins | Nearest neighbours of a vector |
| Result | Rows that match | Ranked list with similarity scores |
| Index | B-tree on column values | ANN index over the vector space |
| Correctness | Deterministic | Approximate by design |
The two are complements. Metadata filters β source, date, language, tenant β are relational thinking applied inside a vector store, and every serious deployment uses them.
4. Filtering Alongside Similarity
Filtering is where implementations differ most. Applying a filter after retrieval can return too few results when the filter is selective; applying it during the graph traversal is harder to implement but keeps recall stable.
If a system must answer "the closest passages, but only from documents updated this month", check how the filter is applied before choosing a store.
5. When You Need One
- You do when similarity search is a core access pattern over hundreds of thousands of items or more, with latency requirements.
- You probably do not for a few thousand chunks. Vectors in memory with a brute-force cosine scan are exact, trivially debuggable, and fast enough.
- You may not need a separate system at all β several general-purpose databases now ship vector indexes, which keeps one operational surface instead of two.
6. Real-World Examples
- A documentation assistant stores one vector per section and filters by product version at query time.
- A media archive embeds images and captions so an editor can search by description rather than by filename.
- A monitoring pipeline embeds newly collected pages daily and flags any that sit close to a defined risk topic.
- A deduplication job clusters scraped product records so near-identical listings collapse into one entry.
7. Common Misconceptions
- "It replaces the primary database." It answers similarity queries. Transactions, joins, and exact lookups still belong elsewhere.
- "Recall is guaranteed." ANN indexes are approximate by design; recall is a tunable traded against latency and memory.
- "Metadata filtering is free." How and when a filter is applied changes both recall and speed, and implementations differ sharply here.
- "Bigger is always better." Below roughly a few thousand vectors, an exact in-memory scan is simpler, faster to debug, and entirely adequate.
8. Summary
A vector database is infrastructure for similarity search: it stores embeddings with their text and metadata, and returns ranked nearest neighbours fast enough to sit inside a request. Approximation is a deliberate design choice, and recall is a tunable rather than a guarantee.
Adopt one when scale or latency demands it, and keep metadata filtering in the design from the start β most disappointing retrieval results are a filtering problem rather than a model problem.