Skip to main content
Indexing is crucial for fast vector similarity search at scale. Qdrant uses specialized index structures to efficiently search through millions or billions of vectors.

Vector Indexing

Qdrant supports two vector index types:

Plain Index (No Index)

Brute-force search through all vectors:
Plain indexes guarantee 100% precision but are only practical for small collections (less than 10K vectors).

HNSW Index

Hierarchical Navigable Small World - the default index for fast approximate search:
HNSW provides excellent recall (>95%) at a fraction of the cost of exhaustive search.

HNSW Algorithm

HNSW builds a multi-layer graph structure for efficient approximate nearest neighbor search:

How HNSW Works

  1. Graph Construction: Vectors are organized into a hierarchical graph with multiple layers
  2. Entry Point: Search starts at the top layer with a single entry point
  3. Greedy Traversal: At each layer, navigate to the closest neighbor until a local minimum is found
  4. Descend: Move down to the next layer and repeat
  5. Bottom Layer: Final refinement at the bottom layer with all vectors

Key Parameters

M - Connectivity

Number of bidirectional links per node:
Higher M means more connections, better quality, but more memory and slower search.

ef_construct - Build Quality

Number of candidates evaluated during construction:
Higher ef_construct improves index quality but increases build time. It does not affect search speed.

ef - Search Quality

Number of candidates evaluated during search (runtime parameter):
Higher hnsw_ef improves recall but slows down search. Adjust per-query based on quality requirements.

full_scan_threshold

When to use brute-force instead of HNSW:
For queries filtering down to few vectors, brute-force is faster than HNSW graph traversal. This threshold automatically switches strategies.

Index Storage

In-Memory HNSW

Fastest option - entire index in RAM:

On-Disk HNSW

Reduces memory usage for large indexes:
On-disk HNSW increases search latency, especially for cold queries. Use for large datasets where memory is limited.

Payload Indexing

Payload indexes enable fast filtering:

Keyword Index

For exact match filtering:
Uses a hash map for O(1) lookups:

Integer Index

For numeric exact match and range queries:
Uses a range tree for efficient range queries:

Text Index

For full-text search:
Uses an inverted index:

Geo Index

For geographic queries:
Uses a spatial index (R-tree) for radius and bounding box queries.

Bool Index

For boolean filtering:

Optimization Process

Qdrant automatically optimizes segments over time:

Segment Types

Optimization Strategy

  1. Plain Segments: New points go into plain (unindexed) segments for fast writes
  2. Threshold: When segment reaches threshold size, optimization is triggered
  3. Index Building: Optimizer builds HNSW index in background
  4. Replacement: Old plain segment is replaced with new indexed segment
Optimization runs in the background without blocking reads or writes.

Quantization

Reduce memory usage with vector quantization:

Scalar Quantization

Convert float32 to int8:
Memory reduction: 4x (from float32 to int8)

Product Quantization

Split vectors into sub-vectors:
Memory reduction: 4x to 64x depending on compression ratio

Binary Quantization

1-bit quantization:
Memory reduction: 32x (from float32 to 1-bit)
Quantization trades memory for accuracy. Always benchmark with your specific data and queries.

Search Optimization

Improves recall for filtered searches:
ACORN helps when filters are very selective (match few points). It improves recall at the cost of some performance.
Disable approximate search:

Performance Tuning

For High Throughput

For High Accuracy

For Large Scale

Best Practices

Create indexes for every payload field you filter on. Unindexed filters are extremely slow.
Start with defaults (M=16, ef_construct=100). Increase M for better recall, ef_construct for better index quality.
Use lower hnsw_ef (32-64) for latency-critical applications, higher (128-256) for accuracy-critical applications.
Quantization dramatically reduces memory usage with minimal accuracy loss. Start with scalar quantization.
Check collection status to ensure optimization is completing successfully.
If your vectors don’t fit in RAM, use on-disk HNSW and quantization.

Collections

Learn how to configure indexes at collection creation

Vectors

Understand what gets indexed

Payloads

Learn about payload indexes

Distance Metrics

Understand distance calculations in indexed search