hashJoin method
CostEstimate
hashJoin({
- required CostEstimate outerPlan,
- required CostEstimate innerPlan,
- required double joinSelectivity,
Implementation
CostEstimate hashJoin({
required CostEstimate outerPlan,
required CostEstimate innerPlan,
required double joinSelectivity,
}) {
// Build phase: hash the inner relation
final buildCost = innerPlan.totalCost +
innerPlan.rows * CostConstants.cpuOpCost;
// Probe phase: for each outer row, probe the hash table
final probeCost = outerPlan.totalCost +
outerPlan.rows * CostConstants.cpuOpCost;
final outputRows =
(outerPlan.rows * innerPlan.rows * joinSelectivity).clamp(1.0, 1e9);
return CostEstimate(
totalCost: buildCost + probeCost,
rows: outputRows,
method:
'HashJoin(${outerPlan.method} ⋈ ${innerPlan.method})',
);
}