You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by hz...@apache.org on 2017/10/04 01:24:29 UTC

[3/7] incubator-trafodion git commit: [TRAFODION-2751] Unnecessary PROBE_CACHE in an index join

[TRAFODION-2751] Unnecessary PROBE_CACHE in an index join

An index join produces unique matches from the index, so
a probe cache would be a waste of resources. Added a check
to suppress probe cache for index joins.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/839f2223
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/839f2223
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/839f2223

Branch: refs/heads/master
Commit: 839f222356ed482215d876414761b4f1fcd54e59
Parents: 4327078
Author: Hans Zeller <hz...@apache.org>
Authored: Tue Oct 3 17:02:52 2017 +0000
Committer: Hans Zeller <hz...@apache.org>
Committed: Tue Oct 3 17:02:52 2017 +0000

----------------------------------------------------------------------
 core/sql/optimizer/OptLogRelExpr.cpp | 4 ++--
 core/sql/optimizer/TransRule.cpp     | 6 ++++++
 core/sql/regress/core/EXPECTED005.SB | 7 +++----
 3 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/839f2223/core/sql/optimizer/OptLogRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/OptLogRelExpr.cpp b/core/sql/optimizer/OptLogRelExpr.cpp
index fb587d5..da94d5a 100644
--- a/core/sql/optimizer/OptLogRelExpr.cpp
+++ b/core/sql/optimizer/OptLogRelExpr.cpp
@@ -2374,7 +2374,7 @@ Join::synthConstraints(NormWA * normWAPtr)
   else
     rightHasUniqueMatches_ = FALSE;
 
-  if (isSemiJoin() OR isAntiSemiJoin())
+  if (isSemiJoin() OR isAntiSemiJoin() OR isIndexJoin_)
     leftHasUniqueMatches_ = TRUE;
 
   // QSTUFF
@@ -2394,7 +2394,7 @@ Join::synthConstraints(NormWA * normWAPtr)
   (void) leftGA.hasCardConstraint(minLeft,maxLeft);
   (void) rightGA.hasCardConstraint(minRight,maxRight);
 
-  if (maxLeft == 1)
+  if (maxLeft == 1 || isIndexJoin_)
     rightHasUniqueMatches_ = TRUE;
 
   if (maxRight == 1)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/839f2223/core/sql/optimizer/TransRule.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/TransRule.cpp b/core/sql/optimizer/TransRule.cpp
index 5d6e846..fdbb58c 100644
--- a/core/sql/optimizer/TransRule.cpp
+++ b/core/sql/optimizer/TransRule.cpp
@@ -1618,6 +1618,12 @@ RelExpr * IndexJoinRule1::makeSubstituteFromIndexInfo(Scan *bef,
   // QSTUFF
   leftScan->synthLogProp();
   rightScan->synthLogProp();
+  // we don't call synthLogProp() for the substitute, since its
+  // logical properties are already stored in the group attributes,
+  // but there are join data members that need to be set. This is
+  // done in the synthConstraints() method, which returns early
+  // if the logical properties are already set.
+  subs->synthConstraints(NULL);
 
   return subs;
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/839f2223/core/sql/regress/core/EXPECTED005.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/EXPECTED005.SB b/core/sql/regress/core/EXPECTED005.SB
index 07f80dc..0cb4d76 100644
--- a/core/sql/regress/core/EXPECTED005.SB
+++ b/core/sql/regress/core/EXPECTED005.SB
@@ -1220,13 +1220,12 @@ H
 S   OPERATOR              LC  RC  TAB_NAME  
 --  --------------------  --  --  ----------
 
-05  ROOT                  4   ?             
-04  NESTED_JOIN           1   3             
-03  PROBE_CACHE           2   ?             
+04  ROOT                  3   ?             
+03  NESTED_JOIN           1   2             
 02  TRAFODION_VSBB_SCAN   ?   ?   T005T4    
 01  TRAFODION_INDEX_SCAN  ?   ?   T005T4    
 
---- 5 row(s) selected.
+--- 4 row(s) selected.
 >>
 >>control query shape cut;