Skip to content

Commit 0e81b75

Browse files
committed
adjust cost factors, move parentheses to correct place
1 parent 2456c48 commit 0e81b75

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sql/memo/coster.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,18 @@ func (c *coster) costRel(ctx *sql.Context, n RelExpr, s sql.StatsProvider) (floa
129129

130130
// If LookupJoin is injective, then there will only be one right lookup per left row
131131
if n.Injective || matchRate == 0 {
132-
return lBest*seqIOCostFactor + lBest*(seqIOCostFactor+randIOCostFactor), nil
132+
return lBest*seqIOCostFactor + lBest*(cpuCostFactor+randIOCostFactor), nil
133133
}
134134

135135
// The total expected number of right row lookups
136136
expectedRightRows := selfJoinCard * matchRate
137137

138138
if expectedRightRows < lBest {
139-
return lBest*(seqIOCostFactor) + (lBest + indexCoverageAdjustment(n.Lookup)*(seqIOCostFactor+randIOCostFactor)), nil
139+
return lBest*(seqIOCostFactor) + (lBest+1+indexCoverageAdjustment(n.Lookup))*(cpuCostFactor+randIOCostFactor), nil
140140
}
141141

142142
// Estimate for reading each left row and each expected right row
143-
return lBest*seqIOCostFactor + expectedRightRows*(seqIOCostFactor+randIOCostFactor), nil
143+
return lBest*seqIOCostFactor + expectedRightRows*(cpuCostFactor+randIOCostFactor), nil
144144
case *ConcatJoin:
145145
return c.costConcatJoin(ctx, n, s)
146146
}

0 commit comments

Comments
 (0)