Machine learning retrieval is a geometric problem. A model encodes your content into vectors in high-dimensional space, and for any query you want to find the stored vectors closest to it. A vector database is the system built to answer that question at scale.
Vectors and what they represent
Machine learning encoder models convert raw data into dense numerical vectors: ordered lists of floating-point numbers, typically a few hundred to a few thousand dimensions. Two inputs with similar meaning land close together in that geometric space; dissimilar ones land far apart. For how those vectors are produced, see what are embeddings?.
A vector database stores these vectors and answers one kind of question: what in my collection is most similar to this query?
Why standard databases don’t work here
A relational database, asked to find the nearest vector to a query, would compute the distance to every stored vector and sort the results. That is a linear scan: O(n) per query. At a million rows it is slow; at a billion it is untenable. Standard indexes like B-trees work on sortable scalars, not multi-dimensional geometry.
Vector databases solve this with approximate nearest neighbor (ANN) indexes: data structures that prune the search space so only a fraction of vectors need to be examined per query.
Two dominant indexing approaches
HNSW (Hierarchical Navigable Small World) builds a layered graph where vectors close in embedding space are connected by edges. A query enters at a sparse upper layer and descends, narrowing toward the nearest match at logarithmic complexity. The algorithm was published by Malkov and Yashunin in IEEE TPAMI (2020) and is the most widely deployed ANN algorithm in production.
IVF (Inverted File Index) clusters vectors into buckets using k-means and limits each query to the nearest clusters. This is the approach underlying FAISS, Meta’s open-source similarity search library, described in Johnson et al. (IEEE Transactions on Big Data, 2019). Under filtered search conditions (where only a subset of vectors are eligible for a query), IVF-based indexes often outperform HNSW, as shown in recent benchmark work (arXiv:2602.11443, 2026).
Why the tradeoff is a feature
“Approximate” is a deliberate engineering choice, not a limitation. Computing the exact nearest neighbor in very high-dimensional spaces degrades toward brute-force scan as a consequence of the curse of dimensionality: at sufficiently high dimension, all points become roughly equidistant, and index pruning provides diminishing returns. ANN indexes accept a small, tunable reduction in recall in exchange for orders-of-magnitude speed gains.
The recall-versus-latency dial is a configuration parameter. A high-stakes retrieval system can be tuned toward 99% recall at higher latency; a real-time feed can accept lower recall for sub-millisecond response. Same algorithm, different settings.
Where it fits in an AI stack
The most common deployment is as the retrieval layer in RAG pipelines (see what is RAG?). A query is encoded into a vector, compared against a stored collection of document embeddings, and the nearest results are passed to the model as grounding context.
The same pattern covers semantic search (ranking results by meaning rather than keyword match) and recommendation (finding items similar to what a user engaged with).
Dedicated database vs. extension
PostgreSQL extensions like pgvector add HNSW indexing to a relational store and are often the right starting point. A standalone vector database only adds value once vector search dominates the workload and the index grows past what Postgres handles at low latency, or when its extended tuning surface (quantization, filtered-search controls) matters.
Most production teams migrate when they hit a concrete limit, not before.
Questions, answered
How is a vector database different from a relational database?
A relational database retrieves rows by exact field values using B-tree or hash indexes. A vector database retrieves items by geometric proximity in high-dimensional space using ANN indexes. Instead of asking for a specific record, you ask for the k items closest to a query vector.
What indexing algorithms does a vector database use?
The two most common are HNSW (a graph-based structure with logarithmic search complexity) and IVF (a partition-based approach that clusters vectors and limits queries to the nearest clusters). Most systems let you choose between them based on your recall and latency requirements.
Do I need a dedicated vector database, or will pgvector work?
pgvector adds HNSW indexing to PostgreSQL and is the right starting point for most projects. A standalone vector database is worth the operational overhead once vector search dominates your traffic and the index outgrows what Postgres handles at low latency.
What does approximate mean in approximate nearest neighbor?
ANN algorithms trade a small, tunable reduction in recall for large speed gains. They examine only a fraction of stored vectors per query rather than all of them. The recall-versus-latency tradeoff is a configurable parameter, not a fixed accuracy loss.
Brief is a team of AI associates you direct in plain language. Opening to a small group at a time.
Request access