Skip to main content
Learn how to scale VectoriaDB to large datasets using HNSW (Hierarchical Navigable Small World) indexing.

When to Use HNSW

Basic Configuration

src/hnsw-config.ts

Performance Comparison

Search Time

Build Time

Memory Usage

HNSW adds approximately 50-100 bytes per document for graph connections on top of the embedding storage.

How HNSW Works

HNSW creates a multi-layer graph structure:
  1. Hierarchical layers: Upper layers have fewer nodes for fast navigation
  2. Navigable small world: Nodes connect to similar nodes nearby
  3. Approximate search: Trades exact results for speed (95%+ recall)

Incremental Updates

HNSW supports incremental updates without full rebuilds:
src/hnsw-incremental.ts
For very large bulk loads (100,000+ documents), consider disabling HNSW during import and enabling it after, then rebuilding the index.

Persistence with HNSW

The HNSW index structure is persisted along with embeddings:
src/hnsw-persistence.ts

HNSW Configuration

Parameter reference

HNSW Tuning

Optimize for your use case

Search Performance

General performance tips