Skip to content

Commit 12a7d49

Browse files
Fixed cardinality estimation bug in CBO (#975)
1 parent 78e14b4 commit 12a7d49

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

ydb/library/yql/core/yql_cost_function.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ TOptimizerStatistics NYql::ComputeJoinStats(const TOptimizerStatistics& leftStat
4444
TVector<TString> joinedTableKeys;
4545

4646
if (IsPKJoin(rightStats,rightJoinKeys)) {
47-
newCard = std::max(leftStats.Nrows,rightStats.Nrows);
47+
newCard = leftStats.Nrows;
4848
joinedTableKeys = leftStats.KeyColumns;
4949
if (leftStats.Type == EStatisticsType::BaseTable){
5050
outputType = EStatisticsType::FilteredFactTable;
@@ -53,7 +53,7 @@ TOptimizerStatistics NYql::ComputeJoinStats(const TOptimizerStatistics& leftStat
5353
}
5454
}
5555
else if (IsPKJoin(leftStats,leftJoinKeys)) {
56-
newCard = std::max(leftStats.Nrows,rightStats.Nrows);
56+
newCard = rightStats.Nrows;
5757
joinedTableKeys = rightStats.KeyColumns;
5858
if (rightStats.Type == EStatisticsType::BaseTable){
5959
outputType = EStatisticsType::FilteredFactTable;

ydb/library/yql/dq/opt/dq_opt_predicate_selectivity.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ double NYql::NDq::ComputePredicateSelectivity(const TExprBase& input, const std:
9696
}
9797
} else {
9898
if (stats->Nrows > 1) {
99-
result = stats->Nrows / 10;
99+
result = 0.1;
100100
}
101101
else {
102102
result = 1.0;

0 commit comments

Comments
 (0)