pub struct JoinOptimizer {
pub max_patterns: usize,
}Expand description
Cost-based join reordering optimizer.
Fields§
§max_patterns: usizeMaximum number of patterns handled by the DP algorithm before falling back to the greedy heuristic.
Implementations§
Source§impl JoinOptimizer
impl JoinOptimizer
Sourcepub fn new(max_patterns: usize) -> Self
pub fn new(max_patterns: usize) -> Self
Create a new optimizer.
max_patterns controls the DP threshold (recommended: ≤12).
Sourcepub fn optimize(&self, patterns: Vec<JoinPattern>) -> JoinPlan
pub fn optimize(&self, patterns: Vec<JoinPattern>) -> JoinPlan
Choose the best join order.
Uses DP when patterns.len() <= max_patterns, greedy otherwise.
Sourcepub fn greedy(patterns: &[JoinPattern]) -> JoinPlan
pub fn greedy(patterns: &[JoinPattern]) -> JoinPlan
Greedy left-deep join reordering.
At each step we pick the unplaced pattern that, when joined with the current pipeline, yields the lowest cost increment.
Sourcepub fn dynamic_programming(&self, patterns: &[JoinPattern]) -> JoinPlan
pub fn dynamic_programming(&self, patterns: &[JoinPattern]) -> JoinPlan
Exact optimal join order via dynamic programming (subset enumeration).
Limited to patterns.len() ≤ 12 to keep exponential blowup manageable.
Sourcepub fn cost_join(left: &JoinPattern, right: &JoinPattern) -> f64
pub fn cost_join(left: &JoinPattern, right: &JoinPattern) -> f64
Incremental join cost when appending right to a pipeline ending with left.
Considers:
- base sizes of both patterns
- selectivity from shared variables (each shared variable reduces cost)
Sourcepub fn build_join_graph(patterns: &[JoinPattern]) -> Vec<JoinEdge>
pub fn build_join_graph(patterns: &[JoinPattern]) -> Vec<JoinEdge>
Build a join graph: one edge for every pair of patterns that share at least one variable.
Return variables that appear in both a and b.
Sourcepub fn merge_patterns(left: &JoinPattern, right: &JoinPattern) -> JoinPattern
pub fn merge_patterns(left: &JoinPattern, right: &JoinPattern) -> JoinPattern
Merge two patterns into the combined pattern produced by their join.
Trait Implementations§
Source§impl Clone for JoinOptimizer
impl Clone for JoinOptimizer
Source§fn clone(&self) -> JoinOptimizer
fn clone(&self) -> JoinOptimizer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for JoinOptimizer
impl RefUnwindSafe for JoinOptimizer
impl Send for JoinOptimizer
impl Sync for JoinOptimizer
impl Unpin for JoinOptimizer
impl UnsafeUnpin for JoinOptimizer
impl UnwindSafe for JoinOptimizer
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.