diff --git a/planner/core/plan_cost_ver2.go b/planner/core/plan_cost_ver2.go index b53d53c845c45..29524a345a3e1 100644 --- a/planner/core/plan_cost_ver2.go +++ b/planner/core/plan_cost_ver2.go @@ -593,6 +593,11 @@ func (p *PhysicalIndexJoin) getIndexJoinCostVer2(taskType property.TaskType, opt // Use an empirical value batchRatio to handle this now. // TODO: remove this empirical value. batchRatio := 6.0 + if _, isIndexLookUp := probe.(*PhysicalIndexLookUpReader); isIndexLookUp { + // IndexJoin + IndexLookUp has the risks to cause massive double-read requests, + // set the batchRatio to a lower value in this case for safety. + batchRatio = 1.5 + } probeCost := divCostVer2(mulCostVer2(probeChildCost, buildRows), batchRatio) p.planCostVer2 = sumCostVer2(startCost, buildChildCost, buildFilterCost, buildTaskCost, divCostVer2(sumCostVer2(probeCost, probeFilterCost, hashTableCost), probeConcurrency))