1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Subquery decorrelation optimization module
//!
//! "Analysis-based subquery decorrelation optimization strategy" — This
//! strategy converts simple PatternApply subqueries into SemiJoin/AntiJoin
//! operations (semi-join unnesting). PatternApply is the correlated
//! subquery operator: the left input is the main pipeline, the right input
//! is the per-row subquery. Unnesting replaces the apply (per-row
//! execution) with a single build/probe pass over both inputs.
//!
//! ## Optimization Strategies
//!
//! Convert the eligible PatternApply subquery into a SemiJoin (EXISTS) or
//! AntiJoin (NOT EXISTS) node. Avoid executing subqueries repeatedly.
//!
//! ## Applicable Conditions
//!
//! 1. The right input for PatternApply is a simple query (single-table
//! scan — optionally a simple two-table inner join tree — wrapped in
//! equality or disjunctive-equality filtering, optionally wrapped in a
//! constant Limit).
//! 2. The filtering conditions are deterministic (excluding rand(), now(),
//! etc.)
//! 3. The complexity of the expressions should be less than 50 (avoid using
//! complex expressions).
//! 4. The subquery estimates that the number of rows is less than 1000
//! (based on statistical information; the stat-free heuristic gate uses
//! the constant [`MAX_BOUNDED_SUBQUERY_ROWS`] limit cap instead).
//!
//! ## Usage Examples
//!
//! ```rust
//! use linkrs_query::optimizer::cost_based::SubqueryUnnestingOptimizer;
//!
//! let optimizer = SubqueryUnnestingOptimizer::new();
//!
//! // let decision = optimizer.should_unnest(&pattern_apply, &analysis, &stats_view, &selectivity);
//! ```
pub use ;
pub use SubqueryUnnestingOptimizer;
pub use ;