Skip to content

Commit

Permalink
edits
Browse files Browse the repository at this point in the history
  • Loading branch information
max-hoffman committed Jul 26, 2024
1 parent 79d3ab9 commit e63da52
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sql/memo/rel_props.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,14 @@ func getJoinStats(leftIdx, rightIdx, leftChild, rightChild sql.Statistic, prefix
return nil, nil
}
if leftIdx.Qualifier() == rightIdx.Qualifier() {
// simplifying assumption, index is unique and will not expand cardinality
return leftChild, nil
expandRatio := leftIdx.RowCount() / leftIdx.DistinctCount()
if expandRatio == 1 {
return leftIdx, nil
} else {
// ths undershoots the estimate, but is directionally correct and faster
// than squaring every bucket
return leftIdx.WithRowCount(leftIdx.RowCount() * expandRatio), nil
}
}
// if either child is not nil, try to interpolate join index stats from child
if !stats.Empty(leftChild) {
Expand Down

0 comments on commit e63da52

Please sign in to comment.