quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbdeshm...@apache.org
Subject incubator-quickstep git commit: Refine estimates for estimateCardinality for TableReference
Date Sat, 05 Nov 2016 15:04:57 GMT
Repository: incubator-quickstep
Updated Branches:
  refs/heads/lower-build-cardinality [created] 1221b06d8


Refine estimates for estimateCardinality for TableReference

- Use exact statistics whenever they are available.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/1221b06d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/1221b06d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/1221b06d

Branch: refs/heads/lower-build-cardinality
Commit: 1221b06d8d3d36df724ecba8a6d5a94a63b3a045
Parents: 70a3d47
Author: Harshad Deshmukh <hbdeshmukh@apache.org>
Authored: Sat Nov 5 10:04:07 2016 -0500
Committer: Harshad Deshmukh <hbdeshmukh@apache.org>
Committed: Sat Nov 5 10:04:07 2016 -0500

----------------------------------------------------------------------
 query_optimizer/cost_model/CMakeLists.txt      | 1 +
 query_optimizer/cost_model/SimpleCostModel.cpp | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1221b06d/query_optimizer/cost_model/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/cost_model/CMakeLists.txt b/query_optimizer/cost_model/CMakeLists.txt
index d616696..43c5cd2 100644
--- a/query_optimizer/cost_model/CMakeLists.txt
+++ b/query_optimizer/cost_model/CMakeLists.txt
@@ -47,6 +47,7 @@ target_link_libraries(quickstep_queryoptimizer_costmodel_SimpleCostModel
 target_link_libraries(quickstep_queryoptimizer_costmodel_StarSchemaSimpleCostModel
                       glog
                       quickstep_catalog_CatalogRelation
+                      quickstep_catalog_CatalogRelationStatistics
                       quickstep_queryoptimizer_costmodel_CostModel
                       quickstep_queryoptimizer_expressions_AttributeReference
                       quickstep_queryoptimizer_expressions_ComparisonExpression

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1221b06d/query_optimizer/cost_model/SimpleCostModel.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/cost_model/SimpleCostModel.cpp b/query_optimizer/cost_model/SimpleCostModel.cpp
index 74b62d6..a803c67 100644
--- a/query_optimizer/cost_model/SimpleCostModel.cpp
+++ b/query_optimizer/cost_model/SimpleCostModel.cpp
@@ -23,6 +23,7 @@
 #include <memory>
 
 #include "catalog/CatalogRelation.hpp"
+#include "catalog/CatalogRelationStatistics.hpp"
 #include "query_optimizer/physical/Aggregate.hpp"
 #include "query_optimizer/physical/NestedLoopsJoin.hpp"
 #include "query_optimizer/physical/HashJoin.hpp"
@@ -92,7 +93,13 @@ std::size_t SimpleCostModel::estimateCardinalityForTopLevelPlan(
 
 std::size_t SimpleCostModel::estimateCardinalityForTableReference(
     const P::TableReferencePtr &physical_plan) {
-  return physical_plan->relation()->estimateTupleCardinality();
+  const std::size_t num_tuples_in_relation =
+      physical_plan->relation()->getStatistics().getNumTuples();
+  if (num_tuples_in_relation == 0) {
+    return physical_plan->relation()->estimateTupleCardinality();
+  } else {
+    return num_tuples_in_relation;
+  }
 }
 
 std::size_t SimpleCostModel::estimateCardinalityForSelection(


Mime
View raw message