Makes hash join into for loop join optimization more aggressive

pull/519/head
Tpt 2 years ago committed by Thomas Tanon
parent 22f990344f
commit adda2d2d7e
  1. 15
      lib/src/sparql/plan_builder.rs

@ -1361,15 +1361,15 @@ impl<'a> PlanBuilder<'a> {
} }
fn new_join(&self, mut left: PlanNode, mut right: PlanNode) -> PlanNode { fn new_join(&self, mut left: PlanNode, mut right: PlanNode) -> PlanNode {
// We first use VALUES to filter the following patterns evaluation
if matches!(right, PlanNode::StaticBindings { .. }) {
swap(&mut left, &mut right);
}
if self.with_optimizations if self.with_optimizations
&& Self::is_fit_for_for_loop_join(&left)
&& Self::is_fit_for_for_loop_join(&right) && Self::is_fit_for_for_loop_join(&right)
&& Self::has_some_common_variables(&left, &right) && Self::has_some_common_variables(&left, &right)
{ {
// We first use VALUES to filter the following patterns evaluation
if matches!(right, PlanNode::StaticBindings { .. }) {
swap(&mut left, &mut right);
}
PlanNode::ForLoopJoin { PlanNode::ForLoopJoin {
left: Rc::new(left), left: Rc::new(left),
right: Rc::new(right), right: Rc::new(right),
@ -1399,9 +1399,8 @@ impl<'a> PlanBuilder<'a> {
match node { match node {
PlanNode::StaticBindings { .. } PlanNode::StaticBindings { .. }
| PlanNode::QuadPattern { .. } | PlanNode::QuadPattern { .. }
| PlanNode::PathPattern { .. } | PlanNode::PathPattern { .. } => true,
| PlanNode::ForLoopJoin { .. } => true, PlanNode::ForLoopJoin { left, right } | PlanNode::HashJoin { left, right } => {
PlanNode::HashJoin { left, right } => {
Self::is_fit_for_for_loop_join(left) && Self::is_fit_for_for_loop_join(right) Self::is_fit_for_for_loop_join(left) && Self::is_fit_for_for_loop_join(right)
} }
PlanNode::Filter { child, .. } | PlanNode::Extend { child, .. } => { PlanNode::Filter { child, .. } | PlanNode::Extend { child, .. } => {

Loading…
Cancel
Save