Expand description
Query optimizer: cost estimation, cardinality, join enumeration.
The planner is organized into these modules:
cost_model– per-operator cost model. Estimates a unitless cost for scans, filters, projections, sorts, hash aggregates, window operators, and join algorithms. Used by the join enumerator to pick a winning plan.cardinality– per-relationRelationStats+CardinalityEstimatorthat turn predicate selectivities into row-count estimates. Equality, range, andLIKEselectivities are all on the same scale (0..=1).join_graph–JoinEdge/JoinGraph– the dataflow graph the enumerator walks.join_enumerator– DPccp (Moerkotte/Neumann 2006). Bitmasku64for relation subsets,HashMapfor the DP cache.optimizer– algebraic rewrites: filter pushdown, facet additivity, Boolean simplification.
Re-exports§
pub use cardinality::column_entropy;pub use cardinality::entropy_cardinality_lower_bound;pub use cardinality::mutual_information_estimate;pub use cardinality::AccessParadigm;pub use cardinality::CardinalityEstimator;pub use cardinality::ColumnStats;pub use cardinality::EdgeSample;pub use cardinality::GraphStats;pub use cardinality::GraphStoreSampler;pub use cardinality::LocalAccessEstimate;pub use cardinality::RelationStats;pub use cardinality::Selectivity;pub use cardinality::GRAPH_AVG_DEGREE_DEFAULT;pub use cardinality::JACCARD_JOIN_SELECTIVITY;pub use cost_model::CostEstimator;pub use cost_model::OperatorCost;pub use cost_model::OperatorKind;pub use join_enumerator::enumerate_dpccp;pub use join_enumerator::enumerate_dpccp_with_cost_estimator;pub use join_enumerator::JoinPlan;pub use join_graph::JoinEdge;pub use join_graph::JoinGraph;pub use join_graph::JoinGraphError;pub use join_graph::JoinGraphResult;pub use join_order::JoinAlgorithm;pub use join_order::JoinCondition;pub use join_order::JoinOrderOptimizer;pub use join_order::JoinOrderResult;pub use join_order::JoinOrderTree;pub use join_order::JoinPredicate;pub use join_order::JoinRelation;pub use optimizer::optimize;pub use optimizer::optimize_with_aggregates;pub use optimizer::optimize_with_aggregates_and_statistics;pub use optimizer::optimize_with_statistics;pub use optimizer::ConstantEvaluator;pub use optimizer::OptimizerConfig;pub use optimizer::SourceStatistics;pub use query_optimizer::IndexScanCandidate;pub use query_optimizer::OptimizerConfig as TreeOptimizerConfig;pub use query_optimizer::QueryOptimizer;pub use text_top_k::plan_text_top_k;pub use text_top_k::TextTopKCapabilities;
Modules§
- cardinality
- Cardinality estimation for SQL predicates and cross-paradigm operator trees.
- column_
pruning - Required source columns and row metadata for physical query projection.
- cost_
model - Per-operator cost model.
- explain
- Explain result rendering and query-block limit placement.
- filter_
pushdown - Qualifier and CTE output-filter pushdown and specialization.
- join_
enumerator - DPccp join enumeration following Moerkotte and Neumann (2006).
- join_
graph - Join graph: nodes are individual relations (a single table or a materialised CTE / subquery output), edges are equijoin predicates. The DPccp enumerator walks this graph to pick a join order.
- join_
order - Join-order optimization.
- mutation_
outputs - Prune unused, side-effect-free mutation-source output slots without changing row shape.
- optimizer
- Plan-native algebraic and cross-paradigm rewrites.
- plan_
cost - Relational execution and replanning costs in the shared physical cost units.
- query_
optimizer - Rule-based and cost-aware operator-tree optimizer.
- retrieval_
planning - Retrieval optimizer setup and checked access estimates over retained catalog inputs.
- source_
filters - Propagate constant equality predicates across equivalent join keys.
- statement_
planning - Statement optimization and prepared-plan estimates over explicit catalog and retrieval inputs.
- text_
top_ k - Physical planning for score-ordered text limits.
- unified_
plan - SQL-owned plan types retained at the planner’s public API boundary.
Structs§
- Assignment
Plan - Conflict
Plan - CteCycle
Plan - Generated cycle mark and path columns for a recursive CTE.
- CtePlan
- A named query child owned by a
QueryPlan. - CteSearch
Plan - Generated traversal-order column for a recursive CTE.
- Delete
Plan - Expression
Plan - Executable scalar IR plus every query-valued descendant it owns.
- Insert
Plan - Merge
Plan - Order
Plan - Projection
Plan - Query
Block Plan - One SELECT block after
WITHand set-operation structure has been pulled into explicit parent/child nodes. - Query
Plan - A relational query with its CTE scope and one relational root.
- Scalar
Order - Scalar
Window Frame - Scalar
Window Spec - Table
Function Plan - One independently resolved and bound function inside a range-function group.
- Update
Plan - View
Check Plan - View
Rule Insert Plan - View
Rule Returning Plan - View
Rule Update Plan
Enums§
- Access
Path Plan - Cross-paradigm access decision made after the relational and scalar portions of a query block have both been lowered.
- Command
Plan - Non-query statement plans. Mutations own physical sources and scalar IR; query-bearing catalog commands own explicit query children. Typed DDL and procedural payloads contain catalog data, never a second SQL dispatcher.
- Compute
Plan - The SELECT-list phase chosen during lowering.
- Conflict
Action Plan - CtePlan
Body - A relational CTE or a command whose RETURNING relation feeds its consumers.
- Join
Execution Strategy - Physical strategy selected for a relational join.
- Merge
When Plan - Relational
Plan - Relational nodes common to ordinary SQL, retrieval SQL, and table/graph functions.
- Scalar
Expr - Scalar
Frame Bound - Source
Plan - The row-producing source below a query block.
- Unified
Plan - One fully lowered SQL statement.
Traits§
- Aggregate
Classifier - Classification hook for engine-registered aggregate functions. Built-in aggregates are always recognised; the callback extends that set without making the planner depend on the engine.
Functions§
- rewrite_
scalar_ expression - Visit one scalar-expression tree in post-order and rewrite each node once.
Type Aliases§
- Subquery
Id - Index into the query children owned by the enclosing expression plan.