For most production vector search workloads, the index choice reduces to one architectural fork: HNSW, a multi-layer proximity graph that delivers extremely fast, high-recall queries but must live largely in memory, or IVF-Flat and its quantized IVF-PQ variant, which partition vector space into Voronoi cells and trade some recall and speed for dramatically lower memory pressure. Milvus engineering documentation frames the boundary plainly: HNSW suits workloads with sufficient memory, low filtering ratios, and a demand for roughly 98%+ recall, while IVF fits memory-constrained deployments where queries carry filtering conditions. This guide maps those mechanics to operational constraints—RAM ceilings, metadata selectivity, and write frequency—so architects can pick an index before an outage forces the decision.
Architectural Foundations: Graphs vs. Voronoi Partitions
HNSW organizes vectors into a hierarchical navigable small-world graph: upper layers hold sparse long-range links for coarse navigation, and each descent funnels the search toward dense lower layers where candidate neighbors are evaluated. Traversal is tunable through three knobs—the connectivity degree M, the build-time candidate list efConstruction, and the query-time search width efSearch—which together govern the recall-latency-build-time triangle. Because navigation requires hopping between arbitrary nodes, the structure is inherently an in-memory index, as Oracle's vector search documentation notes when contrasting it with storage-based alternatives.
IVF takes the opposite approach. A training phase—typically k-means clustering—partitions the dataset into nlist Voronoi cells, each represented by a centroid, the average vector of that partition. At query time the system assigns the query to its nearest centroids and scans only the top nprobe cells with exact distance computation, as documented in Cisco's internal Milvus-based evaluation environment. This is a storage-based index: Oracle's documentation emphasizes that an IVF index "is not constrained by the amount of memory available in the vector pool like an HNSW vector index is," making it viable for datasets that exceed RAM.
IVF-PQ adds product quantization on top, compressing vectors within cells for further memory savings at a recall cost. ScaNN belongs to this same partition-and-quantization family, but granular latency and memory benchmarks for it are not established here, so the comparison below stays with HNSW and the IVF variants.
Memory Footprints and Tuning Parameters
Neither index's memory bill is just the raw vector array. HNSW's footprint scales with the graph itself: every vector node carries edge pointers to its M neighbors across layers, so RAM consumption grows directly with M and total vector count, on top of the embeddings. That is why Milvus's comparison characterizes HNSW memory usage as "relatively high" and IVF's as "relatively low"—IVF's structural overhead is the centroid table, which is modest next to a full graph edge structure.
The tuning parameters encode the same asymmetry. Raising M or efSearch in HNSW buys recall and query robustness with RAM and latency; raising efConstruction slows builds. On the IVF side, AWS's pgvector deep dive explains the lists parameter: more clusters mean fewer vectors per cluster and faster scans, but a higher chance the query lands near a cluster edge, hurting recall. nprobe then governs the recall-latency trade at query time. Critically, IVF recall approaches 100% only when nprobe equals nlist—at which point the search degenerates to exhaustive scanning. Without quantization, Milvus reports IVF recall in the 95%+ range versus HNSW's 98%+.
Query Latency Under Metadata Filtering and Scale
Unfiltered, the two indexes behave as designed: HNSW delivers extremely fast, near-logarithmic-complexity lookups, while IVF's speed depends on how many cells nprobe instructs it to scan. The divergence appears when real-world queries carry metadata predicates—"only this user's vectors," "this time range"—which is the common case, not the exception.
Milvus's engineering comparison documents the failure mode precisely. IVF remains stable under filtering because it performs coarse filtering at the centroid level, narrowing candidates before scanning. HNSW becomes unstable, and especially when the filtering ratio exceeds 90%, "the graph becomes fragmented and may degrade to near full-graph traversal, even slower than brute-force search." The mechanism follows from the architecture: if most nodes the traversal reaches are filtered out, the graph's navigational shortcuts are effectively disabled, and the search must expand ever-wider neighborhoods to satisfy the result count. An index chosen for sub-millisecond unfiltered latency can therefore stall exactly when tenancy filters or access-control predicates are strictest.
Update Friction, Rebuilds, and Liveness Architectures
Neither structure handles continuous ingestion gracefully on its own. HNSW graph construction is slow relative to clustering—Milvus rates IVF build speed as fast because it "only requires clustering," while HNSW needs multi-layer graph construction—and incremental inserts gradually fragment the graph's carefully tuned connectivity. IVF's problem is different: its Voronoi partitions are static once trained, so sustained inserts and deletes drift the data distribution away from the centroids, requiring periodic retraining of the cluster structure.
Production systems therefore bolt on freshness machinery rather than rebuilding monolithic indexes. Course materials from the University of Toronto's CSC2233 vector databases curriculum survey the pattern: a liveness or secondary index absorbs inserts, queries merge the main index answer with the liveness layer's, and a background merge folds changes in. Documented implementations vary—Pinecone pairs a write-ahead log with a liveness layer and secondary index; the Neos research system keeps data on SSD with a GPU flat index and LSM-style ID access; Manu piggybacks on distributed queues such as Kafka or Pulsar with an IVF secondary index. The curriculum also flags the costs: large memory overhead, consistency management, burst handling, and extra I/O. The practical implication is that update-heavy workloads should budget for a two-tier architecture regardless of which base index they choose.
Vector Index Architectural Decision Matrix
The matrix below maps each algorithm's mechanism to its operational bottleneck, using the documented characteristics above. Read it as a diagnostic: find the row matching your binding constraint, and the indicated index follows.
| Constraint | HNSW (multi-layer graph) | IVF-Flat / IVF-PQ (Voronoi cells) |
|---|---|---|
| RAM budget | High: raw vectors plus per-node edge pointers scaling with M; constrained by vector pool memory | Low structural overhead: centroid table plus cell lists; storage-based, usable for datasets exceeding RAM; IVF-PQ compresses further |
| Build / training cost | Slow: multi-layer graph construction | Fast build after k-means training; partitions are static and need periodic retraining under drift |
| Unfiltered latency | Extremely fast, near-logarithmic | Fast, proportional to nprobe |
| Filtered search (90%+ selectivity) | Unstable: graph fragmentation can degrade toward full-graph traversal, slower than brute force | Stable: coarse centroid-level filtering narrows candidates first |
| Recall ceiling | ~98%+ typical | 95%+ uncompressed; 100% only when nprobe = nlist, i.e., exhaustive scan; IVF-PQ lower still |
| Continuous updates | Inserts fragment graph; needs liveness layer or rebuild | Static partitions; needs secondary/liveness index or retraining |
Two thresholds fall out of this mapping. First, when the dataset plus graph overhead will not fit the memory budget, IVF is the only viable primary index—Oracle's documentation is explicit that IVF escapes the vector-pool memory constraint HNSW cannot. Second, when production queries routinely filter out more than 90% of candidates, HNSW's latency guarantee inverts, and IVF's centroid-level pre-filtering becomes the safer architecture even if memory is plentiful.
Production Selection Strategy
Default to HNSW for low-latency, unconstrained memory scenarios; deploy IVF variants when dataset scale exceeds RAM limits or strict memory budgets apply. Concretely: choose HNSW when recall above 98% and sub-millisecond unfiltered latency dominate, filtering ratios stay low, and RAM can absorb the graph; choose IVF-Flat when memory is limited but high query performance and recall are still required, especially with filtering conditions in the query path; choose IVF-PQ when compression is worth the additional recall loss. In every case, plan the freshness layer—WAL-backed liveness index or periodic retraining—before the first sustained write stream, because neither base index tolerates continuous in-place updates alone.
The decision is verifiable in operation: monitor index RAM utilization and query latency percentiles under peak metadata filtering workloads. If p99 latency under your strictest tenant filter approaches brute-force levels on HNSW, or memory utilization trends toward the pool ceiling, the matrix says which migration to make next.
