Use the OptimizersConfig class to tune how Qdrant optimizes segments within a collection. This configuration allows you to control segment sizes, memory usage (memmap), indexing thresholds, and the frequency of optimization tasks.
Key Configuration Parameters:
deleted_threshold (setDeletedThreshold): The minimal fraction of deleted vectors in a segment required to trigger optimization.vacuum_min_vector_number (setVacuumMinVectorNumber): The minimal number of vectors in a segment required to trigger optimization.default_segment_number (setDefaultSegmentNumber): The target number of segments. Setting this to 0 allows Qdrant to automatically select the number based on available CPUs. It is recommended to choose a factor of your search threads.max_segment_size (setMaxSegmentSize): Limits the size of segments in KiloBytes. Lower values prioritize indexation speed; higher values prioritize search speed.memmap_threshold (setMemmapThreshold): Maximum size (in KiloBytes) of vectors to store in-memory per segment. Segments exceeding this will be stored as read-only memmaped files.indexing_threshold (setIndexingThreshold): Maximum size (in KiloBytes) of vectors allowed for a plain index.flush_interval_sec (setFlushIntervalSec): The minimum interval between forced flushes.max_optimization_threads (setMaxOptimizationThreads): The maximum number of threads available for optimization workers.
Note on Units: For size-related parameters, 1Kb is approximately equal to 1 vector of size 256.
use Qdrant\Models\Request\CollectionConfig\OptimizersConfig;
$optimizersConfig = (new OptimizersConfig())
->setDeletedThreshold(0.1)
->setMaxSegmentSize(50000)
->setDefaultSegmentNumber(0)
->setMemmapThreshold(10000);