pub struct SubqueryUnnestingOptimizer { /* private fields */ }Expand description
Subquery decorrelation optimizer
Based on batch plan analysis and statistical information, a decision is made as to whether to convert PatternApply to SemiJoin/AntiJoin.
Implementations§
Source§impl SubqueryUnnestingOptimizer
impl SubqueryUnnestingOptimizer
Sourcepub fn with_max_rows(self, max_rows: u64) -> Self
pub fn with_max_rows(self, max_rows: u64) -> Self
Set a threshold for the maximum number of rows in subqueries
Sourcepub fn with_max_complexity(self, max_complexity: u32) -> Self
pub fn with_max_complexity(self, max_complexity: u32) -> Self
Set a threshold for the maximum complexity.
Sourcepub fn should_unnest(
&self,
pattern_apply: &PatternApplyNode,
analysis: &BatchPlanAnalysis,
stats: &StatsView<'_>,
selectivity: &SelectivityEstimator,
cardinality: &CardinalityFeedbackManager,
advice: &DecorrelationAdvice,
) -> UnnestDecision
pub fn should_unnest( &self, pattern_apply: &PatternApplyNode, analysis: &BatchPlanAnalysis, stats: &StatsView<'_>, selectivity: &SelectivityEstimator, cardinality: &CardinalityFeedbackManager, advice: &DecorrelationAdvice, ) -> UnnestDecision
Determine whether decorrelation should be performed.
§Parameters
pattern_apply: The PatternApply node
analysis: The batch plan analysis result
stats: The space-scoped statistics for the query
selectivity: The selectivity estimator used for filter row estimates
cardinality: The learned per-shape cardinality corrections (may be
consulted to correct the row estimates of both inputs)
advice: Measured execution feedback of both decorrelation paths
§Decision
- Empirical feedback: when past executions of the same shape have measured one path clearly faster, follow the measurement.
- Otherwise compare corrected cost estimates.
Sourcepub fn is_simple_subquery_shape(node: &PlanNodeEnum) -> bool
pub fn is_simple_subquery_shape(node: &PlanNodeEnum) -> bool
Check whether the subquery has a decorrelatable shape: a scan of a
single table (vertex/edge/index) — optionally a simple two-table
inner-join tree — wrapped in equality / disjunctive-equality filters
and projections, capped by a constant Limit within
MAX_BOUNDED_SUBQUERY_ROWS.
Shared with the heuristic decorrelation rule (stat-free shape gate).
Sourcepub fn is_simple_subquery_shape_with_row_bound(
node: &PlanNodeEnum,
max_rows: i64,
) -> bool
pub fn is_simple_subquery_shape_with_row_bound( node: &PlanNodeEnum, max_rows: i64, ) -> bool
Shape gate with a configurable constant row bound.
The stat-free heuristic rule passes MAX_BOUNDED_SUBQUERY_ROWS;
the cost-based decision (should_unnest) passes i64::MAX and lets
the CBO row estimate (step 4 of the decision) bound the subquery
size instead of the static limit cap.
Sourcepub fn is_mark_join_shape(node: &PlanNodeEnum) -> bool
pub fn is_mark_join_shape(node: &PlanNodeEnum) -> bool
Check whether the subquery has a Mark-Join decorrelatable shape.
The Mark-Join path keeps the subquery plan as the join’s right side
and moves the correlated residual into the join condition, so the
right side only needs to be a single-table scan wrapped in arbitrary
(subquery-local) filters and projections, optionally capped by a
constant Limit. Unlike Self::is_simple_subquery_shape the inner
filter conditions may be non-equality: they stay as residual filters
on the materialized right side rather than becoming equi keys.
Sourcepub fn has_bounded_input(node: &PlanNodeEnum) -> bool
pub fn has_bounded_input(node: &PlanNodeEnum) -> bool
Check whether the subquery input is provably bounded: a plain leaf
scan or a constant Limit wrapper with a literal count within
MAX_BOUNDED_SUBQUERY_ROWS.
Sourcepub fn contains_aggregation(node: &PlanNodeEnum) -> bool
pub fn contains_aggregation(node: &PlanNodeEnum) -> bool
Whether the subquery contains an aggregation anywhere in its shape.
Shared with the heuristic decorrelation rule (stat-free shape gate).
Sourcepub fn unnest(
&self,
pattern_apply: PatternApplyNode,
) -> Result<PlanNodeEnum, PlannerError>
pub fn unnest( &self, pattern_apply: PatternApplyNode, ) -> Result<PlanNodeEnum, PlannerError>
Sourcepub fn build_semi_join_from_pattern_apply(
pattern_apply: PatternApplyNode,
) -> Result<PlanNodeEnum, PlannerError>
pub fn build_semi_join_from_pattern_apply( pattern_apply: PatternApplyNode, ) -> Result<PlanNodeEnum, PlannerError>
Shared transformation: PatternApply → SemiJoin / AntiJoin.
PatternApply has semi-join semantics: it keeps the left rows that have (EXISTS) / do not have (NOT EXISTS) a matching right row. The old InnerJoin conversion was unsound for both cases (duplicated left rows and leaked right columns).
The keys are a direct passthrough: PatternApplyNode already carries
per-side key expressions (hash_keys for the left/outer layout,
probe_keys for the right/subquery layout), matching the
SemiJoinNode key convention.
Trait Implementations§
Source§impl Clone for SubqueryUnnestingOptimizer
impl Clone for SubqueryUnnestingOptimizer
Source§impl Debug for SubqueryUnnestingOptimizer
impl Debug for SubqueryUnnestingOptimizer
Auto Trait Implementations§
impl Freeze for SubqueryUnnestingOptimizer
impl RefUnwindSafe for SubqueryUnnestingOptimizer
impl Send for SubqueryUnnestingOptimizer
impl Sync for SubqueryUnnestingOptimizer
impl Unpin for SubqueryUnnestingOptimizer
impl UnsafeUnpin for SubqueryUnnestingOptimizer
impl UnwindSafe for SubqueryUnnestingOptimizer
Blanket Implementations§
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.