Skip to main content

QueryPlanner

Struct QueryPlanner 

Source
pub struct QueryPlanner { /* private fields */ }
Expand description

Unified query planner that handles the complete optimization pipeline.

Unlike the basic Optimizer, QueryPlanner supports ExecutionContext throughout the entire pipeline, enabling context-aware optimizations for both logical and physical plans.

Implementations§

Source§

impl QueryPlanner

Source

pub fn new(ctx: ExecutionContext) -> Self

Creates a new QueryPlanner with the given execution context.

The planner is initialized with default optimization passes:

  • Logical: NotSimplification, AndPredicatePass, CrossProductPass, ImplicitJoinsPass, OuterJoinSimplification, PredicatePushdown, JoinReorder
  • Context-aware logical: IndexSelection
  • Physical: TopNPushdown, OrderByIndexPass, LimitSkipByIndexPass
Source

pub fn with_logical_passes( ctx: ExecutionContext, passes: Vec<Box<dyn OptimizerPass>>, ) -> Self

Creates a QueryPlanner with custom logical passes.

Context-aware passes (IndexSelection, OrderByIndexPass, etc.) are still applied automatically using the provided context.

Source

pub fn context(&self) -> &ExecutionContext

Returns a reference to the execution context.

Source

pub fn plan(&self, plan: LogicalPlan) -> PhysicalPlan

Plans a logical query into an optimized physical plan.

This is the main entry point that runs the complete optimization pipeline:

  1. Apply context-free logical optimizations
  2. Apply context-aware logical optimizations (IndexSelection)
  3. Convert to physical plan
  4. Apply physical optimizations (TopNPushdown, OrderByIndexPass, LimitSkipByIndexPass)
Source

pub fn optimize_logical(&self, plan: LogicalPlan) -> LogicalPlan

Optimizes only the logical plan without converting to physical.

Useful for debugging or when you need to inspect the optimized logical plan.

Source

pub fn to_physical(&self, plan: LogicalPlan) -> PhysicalPlan

Converts a logical plan to physical and applies physical optimizations.

Assumes the logical plan has already been optimized.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.