Skip to main content

Module optimizer

Module optimizer 

Source
Expand description

Cost-based vector index optimizer (selectivity-aware family selection, online learning, persistent stats). See optimizer for details. Cost-based vector index optimizer.

This module implements selectivity-aware index selection for vector search. Given (data_size, dim, requested_recall, query_density) the [index_dispatcher::OptimizerDispatcher] picks the lowest-cost index family that meets the recall floor, with a fallback chain when an observed recall trips the SLA.

Component split:

  • [cost_model] — explicit per-index cost formulas (HNSW: O(log n × M × ef), IVF: O(n / nprobe + n_clusters), LSH: O(K × L × dim + L × bucket), PQ: O(centroids × subquantizers + n × subquantizers)).
  • index_dispatcher — execution-agnostic brain that consults the cost model and chooses a primary + fallback chain.
  • [query_stats] — persisted per-family observation aggregates feeding online cost-weight learning.

The crate-level crate::index_dispatcher::IndexDispatcher wires this brain to concrete vector-index instances (HNSW/IVF/LSH/PQ).

Re-exports§

pub use cost_model::CostEstimate;
pub use cost_model::CostModel;
pub use cost_model::CostWeights;
pub use cost_model::IndexFamily;
pub use cost_model::IndexParameters;
pub use cost_model::WorkloadProfile;
pub use index_dispatcher::dispatcher_with_families;
pub use index_dispatcher::dispatcher_with_parameters;
pub use index_dispatcher::DispatchError;
pub use index_dispatcher::DispatchPlan;
pub use index_dispatcher::DispatcherConfig;
pub use index_dispatcher::OptimizerDispatcher;
pub use query_stats::FamilyStats;
pub use query_stats::QueryObservation;
pub use query_stats::QueryStats;

Modules§

cost_model
Per-index cost formulas for vector search query optimization.
index_dispatcher
Cost-model-driven index dispatcher (the “brain” of the optimizer).
query_stats
Persistent runtime statistics for online cost-model adaptation.