Skip to content

ANN (Approximate Nearest Neighbour)

A search algorithm that finds vectors approximately similar to a query by trading a small loss of accuracy for dramatically faster retrieval at scale.

Approximate Nearest Neighbour (ANN) search is the algorithmic foundation of every production vector database. Its job is to find the stored vectors closest to a query vector — but rather than guaranteeing the exact closest matches, it returns vectors that are very likely to be among the nearest, in exchange for an enormous speed gain.

The reason approximation is necessary is scale. Finding the exact nearest neighbours requires comparing the query against every stored vector, an operation whose cost grows linearly with the dataset. At millions or billions of vectors with sub-100-millisecond latency targets, exhaustive comparison is impossible. ANN algorithms use specialised data structures — navigable graphs, inverted clusters, hash tables — to examine only a small, promising fraction of the data.

The accuracy of an ANN system is measured by recall: the fraction of true nearest neighbours it actually returns. Every ANN index exposes parameters that trade recall against speed, letting operators tune the balance. In practice, well-configured systems achieve 95% or higher recall while searching billions of vectors in milliseconds.