Skip to content

Commit

Permalink
planner: introduce a flag to cost calculation to control some behavio…
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 authored May 10, 2022
1 parent ede6f8c commit 1d2a0b9
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 123 deletions.
2 changes: 1 addition & 1 deletion planner/core/common_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ func (e *Explain) getOperatorInfo(p Plan, id string) (string, string, string, st
estCost := "N/A"
if pp, ok := p.(PhysicalPlan); ok {
if p.SCtx().GetSessionVars().EnableNewCostInterface {
planCost, _ := pp.GetPlanCost(property.RootTaskType)
planCost, _ := pp.GetPlanCost(property.RootTaskType, 0)
estCost = strconv.FormatFloat(planCost, 'f', 2, 64)
} else {
estCost = strconv.FormatFloat(pp.Cost(), 'f', 2, 64)
Expand Down
2 changes: 1 addition & 1 deletion planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func getTaskPlanCost(t task) (float64, error) {
default:
return 0, errors.New("unknown task type")
}
return t.plan().GetPlanCost(taskType)
return t.plan().GetPlanCost(taskType, 0)
}

type physicalOptimizeOp struct {
Expand Down
2 changes: 1 addition & 1 deletion planner/core/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ type PhysicalPlan interface {
Plan

// GetPlanCost calculates the cost of the plan if it has not been calculated yet and returns the cost.
GetPlanCost(taskType property.TaskType) (float64, error)
GetPlanCost(taskType property.TaskType, costFlag uint64) (float64, error)

// attach2Task makes the current physical plan as the father of task's physicalPlan and updates the cost of
// current task. If the child's task is cop task, some operator may close this task and return a new rootTask.
Expand Down
Loading

0 comments on commit 1d2a0b9

Please sign in to comment.