Expand description
Per-index cost formulas for vector search query optimization.
Each formula reflects the asymptotic search cost of a specific approximate nearest-neighbour index, expressed as expected number of distance computations for a single k-NN query. Distance computations dominate query latency for vector search, so distance-count is a robust proxy for wall-clock time.
The formulas implemented here are:
- HNSW:
O(log n × M × ef)—ef * (M * log n)expected probes through the hierarchy. - IVF:
O(n / nprobe + n_clusters)—n_clustersfor coarse centroid selection, thenn / nprobefor fine search inside the probed cells. - LSH:
O(L × bucket_size + K × L × dim)—K * L * dimfor hash evaluation andL * bucket_sizefor candidate scoring. - PQ:
O(centroids × subquantizers + n × subquantizers)— codebook lookup table build then asymmetric distance against every encoded vector.
Each cost is multiplied by a tunable per-index weight obtained from historical statistics, enabling online cost-model adaptation when actual latency measurements drift from the static formula.
All costs are expressed in abstract distance-equivalent units. Higher is more expensive; the dispatcher picks the lowest-cost index that meets the requested recall.
Structs§
- Cost
Estimate - One row of cost-model output: family + estimated cost + estimated recall.
- Cost
Model - Cost-model entrypoint used by the optimizer dispatcher.
- Cost
Weights - Online-learnable weights applied to each per-index formula output.
- Index
Parameters - Tunable per-index parameters that affect the cost formula.
- Workload
Profile - Workload characteristics the cost model needs to estimate per-index cost.
Enums§
- Index
Family - Index families recognised by the optimizer cost model.