Database / Milvus Vector database Interview questions
What is the difference between IVF_FLAT and HNSW indexes in Milvus?
IVF_FLAT clusters vectors into a configured number of buckets (via k-means-style clustering) at index-build time; a search first identifies the most promising nearby clusters, then does an exact, brute-force comparison only within those clusters. HNSW instead builds a multi-layer navigable graph and searches by traversing it, without a clustering step.
| IVF_FLAT | HNSW |
| Clustering-based; search scoped to nearby clusters. | Graph-based; search navigates a multi-layer graph. |
| Generally lower memory usage. | Generally higher memory usage from the graph structure. |
| Recall/speed tunable via the number of clusters searched (nprobe). | Recall/speed tunable via graph search parameters (ef). |
| Simpler to reason about and tune for some workloads. | Often achieves higher recall at comparable latency. |
In practice, HNSW is frequently the default choice for its strong recall/latency balance across many workloads, while IVF_FLAT (and its quantized variants, IVF_SQ8, IVF_PQ) remain attractive specifically when memory is constrained and some additional recall trade-off is acceptable in exchange for a meaningfully smaller index footprint.
More Related questions...