Skill 3.2.5
Choose between using ANN and KNN for vector search
Key Concepts
KNN computes the distance to every candidate vector, so its cost grows linearly with the number of rows. It is the right choice for small sets (tens of thousands of vectors), for queries whose WHERE clause already narrows candidates to a small subset, and as the ground truth when measuring ANN recall. It needs no index and works with any metric.
ANN with a DiskANN vector index visits only a small part of a graph of vectors, so latency stays low for millions of vectors, at the cost of recall below 100%, index build time and storage. The latest vector indexes apply WHERE predicates during the search (iterative filtering) and let the optimizer choose between the index and kNN; the FORCE_ANN_ONLY table hint forces the index.