AI Grimoire
Sheet
statuscommon
difficultyintroductory
timeO(log n)
described2017
revisedtoday

Vector Databases

Finding the nearest vectors to a query is a brute-force scan until the corpus is large. The index that avoids the scan is the product — everything else these systems offer, a normal database already had.

Standing

Commonly usedEstablished and frequently the right choice, but competing with live alternatives rather than having settled the question.

Necessary above a few million vectors and frequently adopted well below that. Postgres with pgvector covers most real workloads.

judged as of 2026-09 · what the labels mean

Theory

Retrieval needs the kk nearest vectors to a query. Exactly, that is a dot product against every vector in the corpus — fine at ten thousand, slow at ten million, and the entire reason this category of software exists.

HNSW, which is what they all run

Hierarchical Navigable Small World graphs are the index behind almost every current system. Vectors become nodes in a layered proximity graph: sparse long edges at the top for coarse navigation, dense short edges at the bottom for precision. A search enters at the top, greedily walks towards the query, and descends.

Logarithmic in corpus size, high recall, and expensive to build — roughly O(nlogn)O(n \log n) with a large constant, and the graph must be in memory.

M=edges per node,ef=candidate list sizeM = \text{edges per node}, \qquad \mathit{ef} = \text{candidate list size}
eq. 1 — the two build parameters

MM around 16 and ef_construction around 200 are reasonable defaults. At query time ef_search sets how hard to look — raise it for recall, lower it for latency. It is the only one of the three you can change after building.

Whether you need one

VectorsReasonable choice
< 100 knumpy, brute force
< 10 Mpgvector, or SQLite + an index
> 10 MQdrant, Milvus, a managed service
research / offlineFAISS

The first row is not a joke. A brute-force scan of 100 000 × 768 floats is a single matmul and takes a few milliseconds — faster than a network round trip to a dedicated service, exact rather than approximate, and with no system to operate.

The landscape

FAISS — Meta’s library, not a database. Every index type, GPU support, excellent for offline and research work. You handle persistence and serving.

pgvector — Postgres extension. Transactions, joins, backups, permissions: everything a database already does, plus HNSW.

Qdrant, Milvus, Weaviate — purpose-built, with filtering, sharding and replication. Worth the operational cost above a few tens of millions of vectors.

Pinecone, and managed offerings — the same, without running it yourself.

Hybrid search

The improvement most worth making. Dense embeddings capture meaning and miss exact tokens — a part number, an error code, a surname. BM25 does the reverse. Run both and fuse the rankings:

RRF(d)=rrankers1k+rankr(d),k60\mathrm{RRF}(d) = \sum_{r \in \text{rankers}} \frac{1}{k + \mathrm{rank}_r(d)}, \qquad k \approx 60
eq. 2 — reciprocal rank fusion, no score calibration needed

RRF combines ranks rather than scores, so the two systems’ incomparable similarity numbers never have to be reconciled. It is a few lines of code and reliably beats either retriever alone.

Brute force
O(n·d)
HNSW query
≈ 1 ms
Recall at that speed
> 95%
HNSW, one million vectors

Related

References

[1]Malkov & Yashunin — Efficient and robust approximate nearest neighbor search using HNSW graphs (2016)arXiv:1603.09320
[2]Johnson et al. — Billion-scale similarity search with GPUs (2017)arXiv:1702.08734
[3]pgvectorgithub