nestedLoopJoin method
CostEstimate
nestedLoopJoin({
- required CostEstimate outerPlan,
- required CostEstimate innerPlan,
- required double joinSelectivity,
- bool innerHasIndex = false,
Implementation
CostEstimate nestedLoopJoin({
required CostEstimate outerPlan,
required CostEstimate innerPlan,
required double joinSelectivity,
bool innerHasIndex = false,
}) {
// Inner scan repeated for each outer row
final innerRepeatCost = innerHasIndex
? innerPlan.totalCost // index lookup once per outer row is OK
: innerPlan.totalCost * outerPlan.rows; // full scan * outer rows
final outputRows =
(outerPlan.rows * innerPlan.rows * joinSelectivity).clamp(1.0, 1e9);
return CostEstimate(
totalCost: outerPlan.totalCost + innerRepeatCost,
rows: outputRows,
method: 'NLJoin(${outerPlan.method} ⋈ ${innerPlan.method})',
);
}