- Control index build performance and memory usage
- Tune accuracy vs performance trade-offs
- Configure storage layout and compression
- Enable Matryoshka embedding support
Samples
Memory-optimized storage with custom neighbors
Plain storage for maximum accuracy
Matryoshka embeddings
High-accuracy build configuration
Build performance considerations
Index builds can be memory-intensive. To improve build performance:maintenance_work_mem is typically 64MB, which may be too low for building indexes on large datasets.
Parameters
storage_layout
Controls how vector data is stored:- memory_optimized (default): Uses Statistical Binary Quantization (SBQ) developed by researchers to compress vectors. Provides excellent performance with reduced memory footprint.
- plain: Stores vectors uncompressed. Uses more memory but may provide slightly higher accuracy. Required for certain distance operators.
num_neighbors
The maximum number of neighbors per node in the graph. This is a key parameter for balancing accuracy and performance:- Lower values (20-50): Faster queries, lower memory, slightly reduced accuracy
- Higher values (50-100): Better accuracy, slower queries, more memory
search_list_size
The size of the candidate list during graph construction (S parameter in DiskANN). Affects index build quality:- Lower values (50-100): Faster index builds, slightly lower quality
- Higher values (100-200): Slower builds, higher quality graph structure
max_alpha
The alpha parameter controls pruning during graph construction:- Lower values (1.0-1.2): More aggressive pruning, faster builds
- Higher values (1.2-2.0): Less aggressive pruning, higher quality graph
num_dimensions
Enables Matryoshka embedding support by indexing only the first N dimensions:- 0 (default): Index all dimensions
- Positive integer: Index only first N dimensions
num_bits_per_dimension
Controls the precision of Statistical Binary Quantization:- 1 bit: Maximum compression, fastest queries, lower accuracy
- 2 bits: Balanced compression and accuracy (default for <900 dimensions)