Small adjust in star schema cost model for # distinct values
Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/023c43a4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/023c43a4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/023c43a4 Branch: refs/heads/fix-iwyu Commit: 023c43a40b145c225c6deab103655156a034fa90 Parents: d1dbb0d Author: Jianqiao Zhu <[email protected]> Authored: Wed Feb 7 15:42:15 2018 -0600 Committer: Jianqiao Zhu <[email protected]> Committed: Fri Feb 23 14:59:06 2018 -0600 ---------------------------------------------------------------------- .../cost_model/StarSchemaSimpleCostModel.cpp | 4 ++-- .../tests/execution_generator/Partition.test | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/023c43a4/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp ---------------------------------------------------------------------- diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp index 5aec4b4..6ab86e5 100644 --- a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp +++ b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp @@ -493,7 +493,7 @@ std::size_t StarSchemaSimpleCostModel::getNumDistinctValues( return stat.getNumDistinctValues(rel_attr_id); } } - return estimateCardinalityForTableReference(table_reference); + return estimateCardinalityForTableReference(table_reference) * 0.1; } bool StarSchemaSimpleCostModel::impliesUniqueAttributes( @@ -527,7 +527,7 @@ bool StarSchemaSimpleCostModel::impliesUniqueAttributes( std::static_pointer_cast<const P::TableReference>(physical_plan); const CatalogRelationStatistics &stat = table_reference->relation()->getStatistics(); - if (stat.hasNumTuples()) { + if (stat.isExact() && stat.hasNumTuples()) { const std::size_t num_tuples = stat.getNumTuples(); for (const auto &attr : attributes) { const attribute_id rel_attr_id = http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/023c43a4/query_optimizer/tests/execution_generator/Partition.test ---------------------------------------------------------------------- diff --git a/query_optimizer/tests/execution_generator/Partition.test b/query_optimizer/tests/execution_generator/Partition.test index 747b969..4b11a04 100644 --- a/query_optimizer/tests/execution_generator/Partition.test +++ b/query_optimizer/tests/execution_generator/Partition.test @@ -116,16 +116,16 @@ WHERE dim_2_hash_partitions.id = fact.id +-----------+--------------------+ |id |char_col | +-----------+--------------------+ -| 2| 2 1.414214| | 4| 4 2.000000| -| 6| 6 2.449490| | 8| 8 2.828427| | 12| 12 3.464102| -| 14| 14 3.741657| | 16| 16 4.000000| +| 24| 24 4.898979| +| 2| 2 1.414214| +| 6| 6 2.449490| +| 14| 14 3.741657| | 18| 18 4.242641| | 22| 22 4.690416| -| 24| 24 4.898979| +-----------+--------------------+ == @@ -193,15 +193,15 @@ GROUP BY fact.score; +------------------------+--------------------+ |score |COUNT(*) | +------------------------+--------------------+ +| 8| 1| | 41.569219381653056| 1| -| 76.367532368147124| 1| | 64| 1| | 52.38320341483518| 1| -| 8| 1| -| 2.8284271247461903| 1| -| 14.696938456699067| 1| +| 76.367532368147124| 1| | 22.627416997969522| 1| | 117.57550765359254| 1| +| 2.8284271247461903| 1| +| 14.696938456699067| 1| | 103.18914671611546| 1| +------------------------+--------------------+ ==
