What is a vector database?
A vector database stores embeddings, lists of numbers that capture meaning, and quickly finds the ones closest to a question.
Rung 1 Explain like I'm 6
Imagine a library where books are not sorted by title, but by what they are about. Dinosaur books sit together, space books sit together, and books about rockets sit right next to the space ones.
Now you ask the librarian, "I want something about going to the Moon." She does not hunt for those exact words. She walks to the space corner and hands you the books nearest to your idea.
A vector database is that library for computers. Every piece of writing gets a spot based on its meaning. When you ask a question, it finds the spots closest to your question, very fast, even with millions of books.
Rung 2 High-school level
An AI model can turn text, images or sounds into embeddings: lists of numbers, called vectors, where similar meanings get similar numbers. "How do I reset my password?" and "I forgot my login" end up close together.
What is a vector database, in simple terms? It is a database built to store those vectors and answer one question fast: which stored vectors are closest to this one? That is called similarity search or nearest-neighbour search.
A normal (relational) database finds exact matches: rows where city = "Pune". A vector database finds the most similar items, even if they share no words. Most vector databases also store the original text and labels next to each vector, so you can filter, for example "only documents from 2026".
Vector database in RAG: a chatbot embeds your question, asks the vector database for the closest chunks of your documents, and pastes them into its prompt before answering.
The hard part is speed. Checking every stored vector one by one is too slow with millions of them, so vector databases use clever indexes that skip most of the comparisons and still find nearly the right answers.
Check yourself: How is a vector database search different from a normal database search?
It returns the items most similar in meaning to the query, not only rows that match exactly.
Rung 3 Undergraduate level
Closeness is measured with a distance or similarity: Euclidean distance, inner product, or cosine similarity, the cosine of the angle between two vectors.
Worked example, a cosine search over four 2-D vectors (all of length 1, so cosine equals the dot product):
- query q = (0.8, 0.6), "how do I send a parcel back?"
- A = (1, 0) "refund policy": 0.8×1 + 0.6×0 = 0.80
- B = (0.6, 0.8) "returning a parcel": 0.48 + 0.48 = 0.96
- C = (0, 1) "delivery times": 0.60
- D = (−0.6, 0.8) "office hours": −0.48 + 0.48 = 0.00
Top-2 results: B, then A. This is exact (brute-force) search: one comparison per stored vector.
Now scale it: 10 million chunks with 1,024-dimension float32 vectors is about 41 GB of raw numbers, and each query needs about 10 billion multiply-adds. Fine for one query on a GPU, too slow and costly for thousands per second.
So vector databases use approximate nearest-neighbour (ANN) indexes. They return most of the true nearest neighbours while looking at a small fraction of the data. Quality is measured as recall@k: of the true top k, what share did the index return?
In Postgres with the pgvector extension, a cosine search is plain SQL using its <=> cosine-distance operator [5]:
SELECT id, body FROM chunks ORDER BY embedding <=> $1 LIMIT 5;
Check yourself: What does recall@10 of 0.95 mean for an ANN index?
On average it returns 95% of the true 10 nearest neighbours; the rest are close but not the closest.
Rung 4 Graduate level
The main index families, all covered in the Faiss library's design [3]:
- Flat: exact, no index. The baseline for measuring recall.
- IVF (inverted file): cluster vectors with k-means, then search only the few clusters nearest the query. More clusters probed means higher recall and slower queries.
- HNSW: a layered graph where search enters a sparse top layer and greedily walks towards the query, dropping to denser layers. Its authors report logarithmic scaling of search cost [1]. Fast and accurate, but memory-hungry because every vector stores neighbour links.
- Quantization: compress vectors, for example with product quantization, so more fit in memory, at some loss of precision. Systems often re-rank the shortlist with full vectors.
- Disk-based graphs: DiskANN (2019) served a billion-point index from one workstation with 64 GB of RAM and an SSD, reaching over 5,000 queries per second, under 3 ms mean latency and 95%+ 1-recall@1 on SIFT1B [2].
Typical knobs, using pgvector's HNSW defaults: m = 16 links per node, ef_construction = 64, and ef_search = 40 candidates per query [5].
Filtering is the classic trap. If filters are applied after the index scan, a query whose filter matches 10% of rows, with ef_search = 40, returns about 4 results on average [5]. pgvector 0.8.0 (2024) added iterative index scans that keep searching until enough rows pass [5].
Vector database vs library vs extension. Faiss is a library: fast search, but you build storage, updates and access control yourself [3]. A vector database adds those. A Postgres extension keeps vectors next to your other data, with limits: pgvector indexes vector columns up to 2,000 dimensions [5].
Rung 5 PhD level
Why approximate? In high dimensions, tree indexes that work well in 2-D or 3-D lose most of their pruning power, so exact search drifts towards a linear scan. Practical systems accept approximate answers instead.
Graph indexes lack guarantees. HNSW's logarithmic behaviour is reported empirically, with a neighbour-selection heuristic that helps on clustered data [1]. There are no worst-case bounds for real datasets. Deletions and frequent updates degrade graph quality, and rebuilding is costly.
Quantization with bounds. Product quantization gives no theoretical error bound. RaBitQ (SIGMOD 2024) compresses a D-dimensional vector to D bits with a sharp error bound and reports a better accuracy-efficiency trade-off than PQ variants [4].
Filtered and hybrid search. Combining similarity with metadata filters, keyword scores or access rules breaks the assumptions behind graph indexes. Pre-filtering can disconnect the graph; post-filtering returns too few results [5]. No method is best across all filter selectivities.
The embedding is the ceiling. A perfect index only finds what the embedding encodes. Weller et al. (2025) proved that the number of distinct top-k sets a single-vector embedding can return is bounded by its dimension, and built LIMIT, a simple dataset that defeats strong embedders [7]. Multi-vector and sparse-dense hybrids escape this at higher storage and search cost.
Open problems:
- Evaluation: recall against exact neighbours is not answer quality in RAG.
- Streaming updates at billion scale without recall decay.
- Cost: keeping indexes in RAM versus SSD or object storage [2][6].
Check yourself: Why can a perfect nearest-neighbour index still return the wrong documents?
It only finds what is closest in embedding space; if the embedding fails to capture the query's meaning, the closest vectors are not the right ones.
Rung 6 State of the art: what experts work on now
Last checked 19 November 2026.
As of 2026-11-19.
The trend is vectors becoming a feature of general storage and databases, alongside dedicated vector databases.
Object storage. Amazon S3 Vectors became generally available on 2 December 2025. AWS lists up to 2 billion vectors per index (40× the preview's 50 million) and up to 20 trillion per bucket, with around 100 ms latency for frequent queries and under a second for infrequent ones [6]. AWS claims up to 90% lower cost than specialised vector databases, a vendor figure [6].
Postgres. pgvector reached version 0.8.7 on 1 October 2026; it supports HNSW and IVFFlat indexes, half-precision and binary vectors, and iterative scans for filtered queries [5].
Compression and libraries. Quantization with error bounds such as RaBitQ (2024) [4] and the Faiss library's documented trade-offs (paper revised October 2025) [3] shape how indexes fit in memory.
Limits of the vector itself. The single-vector bound [7], accepted at ICLR 2026, is why many retrieval stacks now combine vector search with keyword search and reranking.
Practical reading for 2026: most stores can now hold vectors, so the choice turns on scale, filtering and cost, tested on your own queries.
Sources
- Malkov, Yashunin: Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs (2016)
- Subramanya et al.: DiskANN: Fast Accurate Billion-point Nearest Neighbor Search on a Single Node (NeurIPS) (2019)
- Douze et al.: The Faiss library (2024)
- Gao, Long: RaBitQ: Quantizing High-Dimensional Vectors with a Theoretical Error Bound for Approximate Nearest Neighbor Search (SIGMOD) (2024)
- pgvector: Open-source vector similarity search for Postgres (README and changelog) (2026)
- AWS News Blog: Amazon S3 Vectors now generally available with increased scale and performance (2025)
- Weller et al.: On the Theoretical Limitations of Embedding-Based Retrieval (2025)