From adda2d2d7e4192a403543438d68df826478541e0 Mon Sep 17 00:00:00 2001 From: Tpt Date: Wed, 31 May 2023 22:04:04 +0200 Subject: [PATCH] Makes hash join into for loop join optimization more aggressive --- lib/src/sparql/plan_builder.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/src/sparql/plan_builder.rs b/lib/src/sparql/plan_builder.rs index 10d2ffe4..5e7370c1 100644 --- a/lib/src/sparql/plan_builder.rs +++ b/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 { + // We first use VALUES to filter the following patterns evaluation + if matches!(right, PlanNode::StaticBindings { .. }) { + swap(&mut left, &mut right); + } + if self.with_optimizations - && Self::is_fit_for_for_loop_join(&left) && Self::is_fit_for_for_loop_join(&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 { left: Rc::new(left), right: Rc::new(right), @@ -1399,9 +1399,8 @@ impl<'a> PlanBuilder<'a> { match node { PlanNode::StaticBindings { .. } | PlanNode::QuadPattern { .. } - | PlanNode::PathPattern { .. } - | PlanNode::ForLoopJoin { .. } => true, - PlanNode::HashJoin { left, right } => { + | PlanNode::PathPattern { .. } => true, + PlanNode::ForLoopJoin { left, right } | PlanNode::HashJoin { left, right } => { Self::is_fit_for_for_loop_join(left) && Self::is_fit_for_for_loop_join(right) } PlanNode::Filter { child, .. } | PlanNode::Extend { child, .. } => {