quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jianq...@apache.org
Subject incubator-quickstep git commit: Fix SimpleCostModel
Date Sat, 17 Dec 2016 02:32:07 GMT
Repository: incubator-quickstep
Updated Branches:
  refs/heads/min-max-stats 453086bfe -> daa297993


Fix SimpleCostModel


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

Branch: refs/heads/min-max-stats
Commit: daa297993619b575b90290bde29a7c5030d5a67c
Parents: 453086b
Author: Jianqiao Zhu <jianqiao@cs.wisc.edu>
Authored: Fri Dec 16 20:32:00 2016 -0600
Committer: Jianqiao Zhu <jianqiao@cs.wisc.edu>
Committed: Fri Dec 16 20:32:00 2016 -0600

----------------------------------------------------------------------
 query_optimizer/cost_model/SimpleCostModel.cpp | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/daa29799/query_optimizer/cost_model/SimpleCostModel.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/cost_model/SimpleCostModel.cpp b/query_optimizer/cost_model/SimpleCostModel.cpp
index bf6da6a..7808898 100644
--- a/query_optimizer/cost_model/SimpleCostModel.cpp
+++ b/query_optimizer/cost_model/SimpleCostModel.cpp
@@ -94,13 +94,12 @@ std::size_t SimpleCostModel::estimateCardinalityForTopLevelPlan(
 
 std::size_t SimpleCostModel::estimateCardinalityForTableReference(
     const P::TableReferencePtr &physical_plan) {
-  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;
-  }
+  const CatalogRelation *relation = physical_plan->relation();
+  const CatalogRelationStatistics &stat = relation->getStatistics();
+  const std::size_t num_tuples =
+      stat.hasNumTuples() ? stat.getNumTuples()
+                          : relation->estimateTupleCardinality();
+  return num_tuples;
 }
 
 std::size_t SimpleCostModel::estimateCardinalityForSelection(


Mime
View raw message