Skip to content

Flat Index

A brute-force vector index that computes exact nearest neighbours by comparing the query to every stored vector, guaranteeing perfect recall.

A flat index is the simplest possible vector index: it stores all vectors in a plain list and answers a query by comparing it against every single one, returning the exact nearest neighbours. There is no approximation and no clever structure — just an exhaustive, brute-force scan.

Its great virtue is perfect accuracy. Because it checks everything, a flat index always returns the true nearest neighbours, with no recall loss. It also requires no build step or training, supports any distance metric, and is trivial to reason about. For small datasets — up to roughly a hundred thousand vectors — a flat scan is fast enough and often the right choice.

The drawback is that its cost grows linearly with the dataset, so it becomes impractically slow at millions or billions of vectors, which is exactly where approximate indexes like HNSW and IVF take over. Flat indexes remain valuable as a ground-truth reference: you run one to find the exact answers, then measure how closely a faster approximate index matches them when computing recall.