You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2017/10/16 15:10:12 UTC
[1/2] incubator-trafodion git commit: [TRAFODION-2765] Change
heuristics so MDAM is considered more often
Repository: incubator-trafodion
Updated Branches:
refs/heads/master f5fc8dca4 -> a7c9baeba
[TRAFODION-2765] Change heuristics so MDAM is considered more often
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/3b71aeb6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/3b71aeb6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/3b71aeb6
Branch: refs/heads/master
Commit: 3b71aeb6f26389f862536903ff4156d55fa3aca5
Parents: f9ba966
Author: Dave Birdsall <db...@apache.org>
Authored: Thu Oct 5 22:10:11 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Thu Oct 5 22:10:11 2017 +0000
----------------------------------------------------------------------
core/sql/optimizer/ScanOptimizer.cpp | 42 +++++++++++++++++++++++++++++++
core/sql/sqlcomp/DefaultConstants.h | 2 ++
core/sql/sqlcomp/nadefaults.cpp | 4 +++
3 files changed, 48 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3b71aeb6/core/sql/optimizer/ScanOptimizer.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ScanOptimizer.cpp b/core/sql/optimizer/ScanOptimizer.cpp
index be30632..b753be6 100644
--- a/core/sql/optimizer/ScanOptimizer.cpp
+++ b/core/sql/optimizer/ScanOptimizer.cpp
@@ -3001,6 +3001,48 @@ ScanOptimizer::useSimpleFileScanOptimizer(const FileScan& associatedFileScan
,indexDesc
);
+ if (CmpCommon::getDefault(MDAM_FSO_SIMPLE_RULE) == DF_ON)
+ {
+ // Quickly-computed special cases
+
+ if (searchKey.isUnique())
+ return TRUE; // unique access, don't need to consider MDAM
+
+ if (exePreds.entries() == 0) // if searchKey consumed all executor preds
+ return TRUE; // then MDAM can't do better; don't consider
+
+ if (searchKey.getKeyPredicates().entries() == 0)
+ return FALSE; // single subset is a full table scan, so try MDAM
+
+ // General case: If the search key prefix consumes all of
+ // the executor predicates, then we don't need to consider MDAM.
+ // But if there are predicates on key columns that SearchKey
+ // did not pick, then MDAM may have opportunities for reduced
+ // access, and so should be considered.
+
+ ValueIdSet baseColumns;
+ for (ValueId p = exePreds.init(); exePreds.next(p); exePreds.advance(p))
+ {
+ p.getItemExpr()->findAll(ITM_BASECOLUMN,baseColumns,TRUE,TRUE);
+ }
+
+ const ValueIdList & keyColumns = indexDesc->getIndexKey();
+ ValueId baseVid;
+ for (CollIndex i=0; i < keyColumns.entries(); i++ )
+ {
+ if (keyColumns[i].getItemExpr()->getOperatorType() == ITM_INDEXCOLUMN)
+ baseVid = ((IndexColumn*)(keyColumns[i].getItemExpr()))->getDefinition();
+ else
+ baseVid = keyColumns[i];
+
+ if (baseColumns.contains(baseVid))
+ return FALSE; // key column occurs in exePreds; so consider MDAM
+ }
+
+ return TRUE; // SearchKey already handles all key preds; don't consider MDAM
+ }
+
+ // The (old) code below is executed only if CQD MDAM_FSO_SIMPLE_RULE is 'OFF'
if ((! searchKey.isUnique()) &&
(searchKey.getKeyPredicates().entries() > 0))
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3b71aeb6/core/sql/sqlcomp/DefaultConstants.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/DefaultConstants.h b/core/sql/sqlcomp/DefaultConstants.h
index c6b74c9..9fb5d22 100644
--- a/core/sql/sqlcomp/DefaultConstants.h
+++ b/core/sql/sqlcomp/DefaultConstants.h
@@ -1659,6 +1659,8 @@ enum DefaultConstants
MDAM_SUBSET_FACTOR,
+ MDAM_FSO_SIMPLE_RULE,
+
// -------------------------------------------------------------------------
// Makes NO ACTION referential action behave like RESTRICT.
// -------------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3b71aeb6/core/sql/sqlcomp/nadefaults.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp
index 6e9a666..1f01e04 100644
--- a/core/sql/sqlcomp/nadefaults.cpp
+++ b/core/sql/sqlcomp/nadefaults.cpp
@@ -2196,6 +2196,10 @@ SDDkwd__(ISO_MAPPING, (char *)SQLCHARSETSTRING_ISO88591),
// of the key predicates)
DDflt0_(MDAM_CPUCOST_NET_PER_PRED, ".5"),
+ // Added by JIRA TRAFODION-2765: Allows consideration of MDAM
+ // in more general circumstances.
+ XDDkwd__(MDAM_FSO_SIMPLE_RULE, "ON"),
+
// controls the max. number of seek positions under which MDAM will be
// allowed. Set it to 0 turns off the feature.
XDDui___(MDAM_NO_STATS_POSITIONS_THRESHOLD, "10"),
[2/2] incubator-trafodion git commit: Merge [TRAFODION-2765] PR 1258
Consider MDAM costing more often
Posted by db...@apache.org.
Merge [TRAFODION-2765] PR 1258 Consider MDAM costing more often
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/a7c9baeb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/a7c9baeb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/a7c9baeb
Branch: refs/heads/master
Commit: a7c9baeba3043a8a93d41ea459a27516091617ac
Parents: f5fc8dc 3b71aeb
Author: Dave Birdsall <db...@apache.org>
Authored: Mon Oct 16 15:09:33 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Mon Oct 16 15:09:33 2017 +0000
----------------------------------------------------------------------
core/sql/optimizer/ScanOptimizer.cpp | 42 +++++++++++++++++++++++++++++++
core/sql/sqlcomp/DefaultConstants.h | 2 ++
core/sql/sqlcomp/nadefaults.cpp | 4 +++
3 files changed, 48 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a7c9baeb/core/sql/sqlcomp/nadefaults.cpp
----------------------------------------------------------------------