Skip to content

Commit

Permalink
perf: Collapse cross-joins to faster joins (#18633)
Browse files Browse the repository at this point in the history
  • Loading branch information
coastalwhite authored Sep 24, 2024
1 parent 2ffbdcc commit 56bdc4e
Show file tree
Hide file tree
Showing 11 changed files with 696 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/polars-lazy/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ impl LazyFrame {
self
}

/// Toggle collapse joins optimization.
pub fn with_collapse_joins(mut self, toggle: bool) -> Self {
self.opt_state.set(OptFlags::COLLAPSE_JOINS, toggle);
self
}

/// Toggle predicate pushdown optimization.
pub fn with_predicate_pushdown(mut self, toggle: bool) -> Self {
self.opt_state.set(OptFlags::PREDICATE_PUSHDOWN, toggle);
Expand Down
2 changes: 2 additions & 0 deletions crates/polars-plan/src/frame/opt_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ bitflags! {
const ROW_ESTIMATE = 1 << 13;
/// Replace simple projections with a faster inlined projection that skips the expression engine.
const FAST_PROJECTION = 1 << 14;
/// Collapse slower joins with filters into faster joins.
const COLLAPSE_JOINS = 1 << 15;
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/polars-plan/src/plans/expr_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ impl ExprIR {
self.output_name = OutputName::Alias(name)
}

pub(crate) fn set_columnlhs(&mut self, name: PlSmallStr) {
self.output_name = OutputName::ColumnLhs(name)
}

pub fn output_name_inner(&self) -> &OutputName {
&self.output_name
}
Expand Down
Loading

0 comments on commit 56bdc4e

Please sign in to comment.