How-toSelected

Milvus explains when to use HNSW for vector search

Why we picked it

The practical takeaway is that ef is the only lever you can adjust at query time without a rebuild, so teams should exhaust it before touching build parameters that require reindexing. Engineers building RAG or recommendation systems who need a recall-latency tradeoff framework will get a concrete benchmarking procedure: recall@k versus exact search and p95 latency under real concurrency. Teams with RAM constraints get a clear decision path across HNSW_SQ, HNSW_PQ, IVF variants and DISKANN.

Milvus published guidance on when HNSW is the right index choice: it suits low-latency, high-recall vector search when vectors and graph fit comfortably in RAM, such as real-time recommendations or RAG retrieval. HNSW works by searching a layered graph, where upper layers guide the search toward promising regions and the bottom layer examines neighborhoods in detail.

Body

Three parameters govern behaviour. M controls graph density: more links improve recall but increase RAM usage and slow index builds. efConstruction sets how many candidate neighbors are considered during the build, trading build time for graph quality. ef controls query-time search breadth, improving recall at higher latency, and can be tuned without rebuilding the index. For tight RAM, HNSW_SQ and HNSW_PQ compress vectors while keeping the graph; IVF_FLAT and IVF_PQ serve cluster-based search, and DISKANN on a fast SSD handles datasets exceeding RAM.

Milvus recommends starting with ef tuning on representative queries, measuring recall@k against exact search results, and tracking p95 latency at expected concurrency before revisiting build settings.

Original · Milvus

𝗪𝗵𝗲𝗻 𝘀𝗵𝗼𝘂𝗹𝗱 𝘆𝗼𝘂 𝘂𝘀𝗲 𝗛𝗡𝗦𝗪 𝗶𝗻 𝗠𝗶𝗹𝘃𝘂𝘀? HNSW is a good starting point for low-latency, high-recall vector search when the vectors and the graph fit comfortably in RAM. Think real-time recommendations or RAG retrieval. HNSW searches a layered graph. The upper layers guide it toward promising areas, and the bottom layer searches those neighborhoods in more detail. • 𝗠 controls how densely connected the graph is. More links can improve recall, use more RAM, and slow down index builds. • 𝗲𝗳𝗖𝗼𝗻𝘀𝘁𝗿𝘂𝗰𝘁𝗶𝗼𝗻 controls how many candidate neighbors HNSW considers during the build. A larger pool can improve graph quality and takes longer to evaluate. • 𝗲𝗳 controls how broadly HNSW searches at query time. Raising it can improve recall at the cost of higher latency. You can tune it without rebuilding the index. If RAM is tight, HNSW_SQ and HNSW_PQ compress the vectors while keeping the graph. For cluster-based search, IVF_FLAT keeps the original vectors and IVF_PQ compresses them. If the dataset exceeds available RAM, benchmark DISKANN on a fast SSD. Start by tuning ef on representative queries. Measure recall @k against exact search results and track p95 latency at your expected concurrency. Revisit the build settings if query-time tuning falls shor milvus.io/docs/hnsw.md us #Milvus un #VectorDatabase s #OpenSource BK28axJ #Milvus #VectorDatabase #OpenSource

Industry Coordinates & Source Verification

This report is categorized under AITOP's "How-to" desk. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include Milvus, HNSW, vector databases, RAG.

Source attribution: curated from Milvus (@milvusio).

Spotted an error in the summary or translation? Tell us