vs HNSW

Comparison with HNSW #

HNSW (Hierarchical Navigable Small World) is one of the widely used libraries implementing Hierarchical Navigable Small World graphs, and forms the basis for most commercial offerings such as Milvus, Qdrant, etc. It’s widely adopted in recommendation systems, search engines, and as a core component in other vector databases due to its excellent speed-recall trade-off.

Query Time vs. Recall@10 Comparison #

Query Time vs Recall Graph

Detailed Comparison (SIFT1M, k=10) #

Performance Metrics #

LibraryGeometric Mean QPSMedian QPSQPS@95%Weighted Avg QPSAUC ValueAUC Normalized
PatANN182,526.33190,849.94357,320.88223,090.2983,919.87223,090.29
HNSWLib20,503.9724,161.2153,226.4032,429.1221,098.0632,429.12

Recall at Different QPS Levels #

LibraryRecall@10,000 QPSRecall@50,000 QPSRecall@100,000 QPSRecall@200,000 QPS
PatANN0.999910.999910.999910.99944
HNSWLib0.996240.68671--

Algorithm Parameters #

LibraryPointsMin KMax KK RangeMin EpsilonMax EpsilonMedian Epsilon
PatANN2800.623740.999910.376170.7242010.99718
HNSWLib1400.349130.999720.650590.412190.999980.96344

Key Findings #

PatANN demonstrates significantly better performance compared to HNSW implementations, with approximately 8.9x higher geometric mean QPS and 6.9x higher weighted average QPS. While HNSW maintains excellent recall (99.6%) at lower QPS levels (10,000), it experiences substantial degradation at higher throughput, dropping to 68.7% at 50,000 QPS and unable to maintain performance at higher QPS levels.

The graph-based approach of HNSW offers good precision but comes with scalability limitations compared to PatANN’s pattern-aware partitioning. HNSWLib requires careful tuning of the graph construction parameters (M and ef_construction) to balance build time, index size, and query performance, whereas PatANN offers more consistent performance across varying workloads with less parameter sensitivity.