aiondb-optimizer

Lowers a LogicalPlan into a PhysicalPlan. Applies predicate pushdown, projection pruning, transitive-predicate inference, outer-join simplification, join reordering, access-path selection, and HNSW / vector-search planning. Costs are computed against catalog statistics fetched through a CatalogReader.

cargo

[dependencies]
aiondb-optimizer = { path = "../aiondb-optimizer" }

modules

modulepurpose
physical_builderDrives the logical-to-physical lowering and emits PhysicalPlan nodes.
access_pathPicks an access path for each scan (sequential, index lookup, index range, vector search).
costPlanCost and per-operator costing helpers.
rulesLogical-rewrite rules dispatched from the top of optimize.
predicate_pushdownPushes filters past joins and projections.
projection_pruningDrops columns that downstream operators do not need.
transitive_predicatesDerives a = b && b = c => a = c style predicates to enable extra index lookups.
outer_join_simplifyConverts outer joins to inner joins where the outer side is provably non-null.
join_reorderReorders inner-join chains by estimated row count.
graph_optimizerCypher-specific rewrites.
distributedLowering for DistributedPhysicalPlan fragments.

key types

entry points

itemrole
Optimizer::new(catalog)Build an optimizer over a CatalogReader.
Optimizer::optimize(req)Lower a LogicalPlan to PhysicalPlan, returning a DbResult<PhysicalPlan>.
Optimizer::optimize_cypher_with_stats(...)Cypher-specific optimization path that accepts external statistics.

example

use std::sync::Arc;
use aiondb_catalog::CatalogReader;
use aiondb_core::TxnId;
use aiondb_optimizer::{OptimizeRequest, Optimizer};
use aiondb_plan::LogicalPlan;

fn lower(catalog: Arc<dyn CatalogReader>, logical: LogicalPlan, txn: TxnId) {
    let optimizer = Optimizer::new(catalog);
    let req = OptimizeRequest {
        logical_plan: logical,
        txn_id: txn,
    };
    let physical = optimizer.optimize(req).expect("optimize");
    let _ = physical;
}