efSearch (short for effective search) is a runtime parameter in the Hierarchical Navigable Small World (HNSW) graph algorithm that controls the size of the dynamic candidate list during the greedy graph traversal. It directly governs the trade-off between search accuracy (recall) and query latency by determining how many neighboring nodes are explored at each layer of the graph. A higher efSearch value increases recall at the cost of higher latency, as the algorithm examines more potential nearest neighbors.
Glossary
efSearch (HNSW Parameter)

What is efSearch (HNSW Parameter)?
A critical parameter for tuning the speed-accuracy trade-off in vector similarity search.
In practice, efSearch is tuned alongside the construction parameter efConstruction and the number of nearest neighbors requested (k). For low-latency production systems, engineers often set efSearch just high enough to meet a target recall threshold, such as 0.95. This parameter is distinct from nprobe used in IVF indexes but serves a similar purpose: managing the fundamental recall-latency trade-off inherent to all approximate nearest neighbor (ANN) search algorithms by controlling search breadth.
Key Characteristics and Impact of efSearch
In the Hierarchical Navigable Small World (HNSW) algorithm, efSearch is a dynamic list size parameter that controls the size of the priority queue during the greedy graph traversal, directly governing the trade-off between search accuracy and query latency.
Primary Function: Dynamic Candidate List
The efSearch parameter sets the size of the dynamic candidate list (priority queue) maintained during the greedy graph traversal on each layer of the HNSW graph. A higher value means the algorithm explores more potential nearest neighbor paths at each step, increasing the likelihood of finding the true nearest neighbors but requiring more distance computations.
- Core Mechanism: During search, HNSW starts from an entry point and iteratively moves to the neighbor closest to the query.
efSearchdetermines how many of the closest discovered nodes are kept in the queue for consideration as the next hop. - Direct Control: It is the primary lever for adjusting the exploration breadth of the search, as opposed to
efConstruction, which controls the graph's connectivity during index building.
Governs the Recall-Latency Trade-off
efSearch is the principal parameter for managing the fundamental recall-latency trade-off in HNSW-based retrieval.
- High
efSearch(e.g., 200-500): Maximizes recall (search accuracy) by extensively exploring the graph. This is critical for applications requiring high precision, such as legal document retrieval or factual QA in RAG, but results in higher query latency and CPU usage. - Low
efSearch(e.g., 10-50): Minimizes latency for high-throughput, real-time applications like recommendation systems or chat. However, this risks lower recall as the search may terminate in a local minimum of the graph, missing better candidates. - Tuning Required: The optimal value is dataset and application-specific, found through empirical benchmarking of recall@k against latency targets.
Search-Time vs. Build-Time Parameter
A critical distinction is that efSearch is a search-time parameter, unlike efConstruction or M which are index-time parameters. This means it can be adjusted dynamically without rebuilding the HNSW index.
- Operational Flexibility: Allows a single, static index to serve multiple query profiles. For example, a backend system could use a low
efSearchfor general user queries but switch to a highefSearchfor a critical, accuracy-sensitive administrative search. - Performance Tuning: Engineers can A/B test different
efSearchvalues in production to optimize for changing latency Service Level Agreements (SLAs) or accuracy requirements. - Implementation: Set as an argument in the search function of libraries like FAISS or Weaviate, e.g.,
index.search(query, k=10, params={'efSearch': 128}).
Interaction with Other HNSW Parameters
The effect of efSearch is interdependent with other key HNSW parameters, primarily M (the number of bi-directional graph connections per node).
- With a High
M: The graph is more densely connected, offering more potential paths. A moderateefSearchmay suffice for high recall, as good candidates are readily reachable. - With a Low
M: The graph is sparser. A higherefSearchis often necessary to achieve the same recall, as the algorithm needs to explore a broader frontier to find the best path through fewer connections. - Rule of Thumb:
efSearchshould generally be set higher than the desired number of results (k) to ensure the priority queue contains enough high-quality candidates to select the finalkneighbors from. A common heuristic isefSearch = k * 2tok * 10, validated by testing.
Impact on Multi-Layer Traversal
HNSW's efficiency stems from its hierarchical, multi-layered graph. efSearch controls the traversal on each layer, but its impact is most pronounced on the bottom layer where the final, precise search occurs.
- Top-Down Search: Search begins on a high, sparse layer to find a good entry point for the layer below.
efSearchis applied on every layer, but the candidate list size is small on upper layers. - Bottom-Layer Dominance: Over 90% of search time is spent on the bottom (layer 0), which contains all data points. The
efSearch-sized priority queue on this layer dictates the total number of distance computations, which is the primary driver of latency. - Memory Access Patterns: A large
efSearchqueue can lead to less cache-friendly memory access as the algorithm jumps between distant graph nodes, adding hidden latency costs.
Benchmarking and Tuning Strategy
Determining the optimal efSearch is an empirical process central to retrieval latency optimization.
- Standard Methodology:
- Fix the index (parameters
M,efConstruction). - Run a benchmark query set across a range of
efSearchvalues (e.g., 16, 32, 64, 128, 256). - For each value, measure average latency and recall@k (against ground truth).
- Plot the recall-latency curve to identify the knee point where latency increases sharply for diminishing recall gains.
- Fix the index (parameters
- Production Monitoring: Track P95/P99 latency and recall metrics in production after deployment. Auto-scaling systems can use
efSearchas a dynamic knob to maintain SLAs under varying load. - Example Trade-off: On a 1M vector dataset, increasing
efSearchfrom 32 to 128 might improve recall@10 from 0.85 to 0.97 but double query latency from 2ms to 4ms. The business requirement dictates the acceptable compromise.
efSearch Tuning Guidelines and Trade-offs
Practical guidance for tuning the efSearch parameter in the HNSW algorithm, outlining the direct impact on retrieval performance and system resource consumption.
| Performance Characteristic | Low efSearch (e.g., 10-50) | Medium efSearch (e.g., 100-200) | High efSearch (e.g., 400-800) |
|---|---|---|---|
Primary Search Latency | < 1 ms | 5-20 ms | 50-200 ms |
Recall @ 10 (Typical) | 85-92% | 95-98% | 99%+ |
Memory Bandwidth Pressure | Low | Medium | High |
CPU Cache Efficiency | High | Medium | Low |
Suitability for Pre-filtering | High | Medium | Low |
Impact on P99 Latency | Minimal | Moderate | Significant |
Recommended Use Case | High-throughput, low-latency APIs | Balanced production RAG systems | Batch processing or maximum recall tasks |
Implementation in Libraries and Systems
The efSearch parameter is a critical runtime knob for tuning the HNSW algorithm's performance. Its implementation varies across popular vector search libraries, each offering specific APIs and default behaviors.
Frequently Asked Questions
`efSearch` is a critical tuning parameter in the Hierarchical Navigable Small World (HNSW) graph algorithm that directly controls the trade-off between search accuracy and query latency in vector similarity search.
efSearch (short for dynamic candidate list size for search) is a runtime parameter in the HNSW algorithm that controls the size of the dynamic priority queue used during the greedy graph traversal. When searching the HNSW graph for a query vector, the algorithm maintains a priority queue (often a min-heap) of the most promising candidate nodes to visit next, ordered by their distance to the query. The efSearch parameter sets the maximum allowed size of this queue. A larger queue allows the search to explore more potential paths and retain a broader set of nearest neighbor candidates, increasing the probability of finding the true nearest neighbors (higher recall) at the cost of more distance computations and longer latency.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
These core concepts and parameters are essential for engineers tuning the performance of vector search systems, particularly those built on the HNSW algorithm.
Hierarchical Navigable Small World (HNSW)
HNSW is the underlying graph-based algorithm where efSearch operates. It constructs a multi-layered graph where long-range connections on higher layers enable fast entry points, and greedy traversal on lower layers refines the search. Key properties include:
- Logarithmic scaling of search complexity.
- High recall with relatively low computational cost.
- Dynamic insertion of new vectors without full index rebuilds.
efSearchcontrols the size of the dynamic candidate list during this greedy graph traversal, directly impacting the algorithm's exploration depth.
nprobe (IVF Parameter)
nprobe is the analogous search-time parameter for Inverted File Index (IVF) systems. It controls the number of nearest clusters (Voronoi cells) to search during a query.
- Low
nprobe: Searches fewer clusters, resulting in lower latency but potentially lower recall. - High
nprobe: Searches more clusters, increasing recall at the cost of higher latency. WhileefSearchmanages exploration depth within an HNSW graph,nprobecontrols the breadth of search across IVF partitions. Both are primary knobs for the recall-latency trade-off in their respective ANN algorithms.
Recall-Latency Trade-off
This is the fundamental compromise governed by parameters like efSearch. Recall measures the fraction of true nearest neighbors found by the approximate search. Latency is the time taken to return results.
- Increasing
efSearchtypically improves recall by allowing the algorithm to explore more candidate nodes, but it increases latency due to more distance computations and priority queue operations. - The optimal setting is application-dependent: a recommendation system may prioritize low latency with moderate recall, while a legal e-discovery tool may maximize recall regardless of higher latency.
Approximate Nearest Neighbor Search (ANN)
ANN is the overarching problem that HNSW with efSearch solves. It involves finding vectors close to a query vector in high-dimensional space, sacrificing perfect accuracy for orders-of-magnitude speedup over exact search (K-NN).
- Core Challenge: Balancing search quality, speed, and memory usage.
- Algorithm Families: Includes graph-based (HNSW), hashing-based (LSH), and quantization-based (PQ, IVF) methods.
efSearchis a critical parameter for tuning the quality-speed balance within the graph-based ANN paradigm.
Multi-Stage Retrieval
A system architecture where efSearch is tuned in the context of a larger pipeline. A fast first-stage retriever (e.g., HNSW with a low efSearch) fetches a broad candidate set (e.g., 100-1000 documents). A slower, more accurate second-stage reranker (e.g., a cross-encoder model) then scores and reorders these candidates.
- Optimization Strategy:
efSearchcan be set aggressively low in the first stage because the reranker will correct for lower recall. - Result: Optimizes the overall system precision-latency trade-off, allowing the vector index to focus on speed.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us