Vector Similarity Search: Metrics & Approximate Methods › Complexity Comparison
Language AI HandbookAll chapters Vector Similarity Search: Metrics & Approximate Methods › Complexity ComparisonOne section · Sections in this chapter6 / 11 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Understanding the computational complexity of different search strategies helps you make informed decisions about which approach fits your scale. The differences between exact and approximate search are not marginal: they are qualitative changes in how query cost grows with collection size. Exact search grows linearly, meaning that doubling the collection size doubles the query time. Approximate methods grow sublinearly, meaning that doubling the collection size increases query time by much less than a factor of two. At large scales, this distinction is the difference between a system that responds in milliseconds and one that takes seconds.

The table below summarizes the trade-offs across the major search strategies. Each row captures a different aspect of system behavior, from query-time latency to memory consumption, and the columns reveal how these aspects vary across the four principal approaches.
| Property | Exact Search | Graph-based ANN | IVF-based ANN | Quantized ANN |
|---|---|---|---|---|
| Query time | , | |||
| Index build time | ||||
| Memory | ||||
| Recall guarantee | 100% | Tunable (95-99%+) | Tunable (90-99%+) | Tunable (85-95%+) |
| Best for | Small collections, ground truth | Large-scale, low latency | Very large scale | Memory-constrained |
where:
- : the number of graph connections per node (in HNSW)
- : the centroid storage cost (in IVF)
- : the number of clusters (in IVF)
- : the compressed dimension (in quantization methods)
- : the number of vectors in the collection
- : the dimensionality of the vector space
Several patterns in this table deserve attention. First, notice that exact search has index build time, because there is no index to build: you simply store the raw vectors. All approximate methods require an upfront investment in index construction, whether that is building a graph (HNSW), clustering vectors into partitions (IVF), or learning codebooks (quantization). This build cost is amortized over all future queries, which makes it worthwhile when the collection will be queried many times.
Second, observe the memory column. Graph-based methods add connections per vector on top of the full vector storage, which increases memory usage but enables the fast navigable graph traversal that gives HNSW its speed advantage. IVF methods add a relatively modest centroid storage cost (proportional to the number of clusters, not the number of vectors). Quantization methods achieve the greatest memory savings by replacing the full -dimensional vector with a compressed code of dimension , where can be 8 to 32 times smaller than .
The graph-based approach (HNSW) typically offers the best recall at a given query speed, which is why it has become the dominant ANN method. However, it uses more memory than quantization-based approaches because it stores both the full vectors and the graph edges.