Skip to content

Commit 7a77707

Browse files
committed
use selfJoinCard for expectedRightRows estimate
1 parent a5d46f4 commit 7a77707

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sql/memo/coster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ func (c *coster) costRel(ctx *sql.Context, n RelExpr, s sql.StatsProvider) (floa
132132
}
133133

134134
// The total expected number of right row lookups
135-
expectedRightRows := lBest * matchRate
135+
expectedRightRows := selfJoinCard * matchRate
136136
// Estimate for reading each left row and each expected right row
137-
return lBest*seqIOCostFactor + expectedRightRows*randIOCostFactor, nil
137+
return lBest*seqIOCostFactor + expectedRightRows*(randIOCostFactor+seqIOCostFactor), nil
138138
case *ConcatJoin:
139139
return c.costConcatJoin(ctx, n, s)
140140
}

0 commit comments

Comments
 (0)