Skip to main content

Module query_optimizer

Module query_optimizer 

Source
Expand description

Rule-based and cost-aware operator-tree optimizer.

Walks an OperatorTree and applies algebraic, graph, and physical rewrites:

  1. simplify_algebra – address-independent idempotence / absorption / empty elimination on membership-only Intersect / Union operands. Score-bearing operands remain distinct because posting-list merges add their scores.
  2. push_filters_down – sink Filter into Intersect children when the field applies.
  3. push_graph_pattern_filters – fold vertex / edge property filters into PatternMatch constraints.
  4. push_filter_into_traverse – absorb vertex predicates into Traverse so BFS prunes during expansion.
  5. push_filter_below_graph_join – move filters past graph joins when the field belongs to the left side.
  6. fuse_join_pattern – merge intersected PatternMatch operators that share a vertex variable.
  7. reorder_intersect – sort Intersect children by estimated operator cost (cheapest first).
  8. reorder_fusion_signals – sort fusion signals by cost; graph operators receive a 0.5x discount when graph stats are available.
  9. apply_index_scan – substitute leaf Filter with IndexScan when a covering index is registered and cheaper.

Vector-threshold operands remain distinct: intersection adds each raw cosine score, and approximate query-vector equality cannot preserve threshold support. Rewrites must also retain invalid-threshold errors.

Structs§

IndexScanCandidate
Query-local physical index candidate supplied by an engine catalog.
OptimizerConfig
Fluent configuration for the optimizer pipeline. Lets callers disable individual stages for testing without poking at private fields.
QueryOptimizer
Operator-tree query optimizer.