Skip to content

Commit

Permalink
Fixed cardinality estimation bug in CBO (#975)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelvelikhov authored Jan 12, 2024
1 parent 78e14b4 commit 12a7d49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ydb/library/yql/core/yql_cost_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TOptimizerStatistics NYql::ComputeJoinStats(const TOptimizerStatistics& leftStat
TVector<TString> joinedTableKeys;

if (IsPKJoin(rightStats,rightJoinKeys)) {
newCard = std::max(leftStats.Nrows,rightStats.Nrows);
newCard = leftStats.Nrows;
joinedTableKeys = leftStats.KeyColumns;
if (leftStats.Type == EStatisticsType::BaseTable){
outputType = EStatisticsType::FilteredFactTable;
Expand All @@ -53,7 +53,7 @@ TOptimizerStatistics NYql::ComputeJoinStats(const TOptimizerStatistics& leftStat
}
}
else if (IsPKJoin(leftStats,leftJoinKeys)) {
newCard = std::max(leftStats.Nrows,rightStats.Nrows);
newCard = rightStats.Nrows;
joinedTableKeys = rightStats.KeyColumns;
if (rightStats.Type == EStatisticsType::BaseTable){
outputType = EStatisticsType::FilteredFactTable;
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/yql/dq/opt/dq_opt_predicate_selectivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ double NYql::NDq::ComputePredicateSelectivity(const TExprBase& input, const std:
}
} else {
if (stats->Nrows > 1) {
result = stats->Nrows / 10;
result = 0.1;
}
else {
result = 1.0;
Expand Down

0 comments on commit 12a7d49

Please sign in to comment.