indexEqualityScan method
Implementation
CostEstimate indexEqualityScan(
String table, String column, dynamic value) {
final ts = stats.get(table);
if (ts == null) {
return const CostEstimate(
totalCost: 10.0, rows: 1.0, method: 'IndexScan(unknown)');
}
final cs = ts.column(column);
final rowCountSafe = ts.rowCount < 1 ? 1 : ts.rowCount;
final sel = cs?.equalitySelectivity() ?? (1.0 / rowCountSafe);
final maxRows = rowCountSafe.toDouble();
final matchRows = (rowCountSafe * sel).clamp(1.0, maxRows);
final cost = CostConstants.indexFetchCost +
matchRows * (CostConstants.randomIoCost + CostConstants.cpuTupleCost);
return CostEstimate(
totalCost: cost,
rows: matchRows,
method: 'IndexScan($table.$column=$value)');
}