Skip to content

Commit 57b0825

Browse files
authored
planner: set the default of the tidb_cost_model_version correctly (#61608) (#62184)
close #61565
1 parent f43a133 commit 57b0825

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

pkg/planner/core/plan_cost_ver1.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/pingcap/tidb/pkg/planner/util/optimizetrace"
3030
"github.com/pingcap/tidb/pkg/sessionctx/variable"
3131
"github.com/pingcap/tidb/pkg/statistics"
32+
"github.com/pingcap/tidb/pkg/util/intest"
3233
"github.com/pingcap/tidb/pkg/util/paging"
3334
)
3435

@@ -87,6 +88,7 @@ func (p *PhysicalProjection) GetCost(count float64) float64 {
8788

8889
// GetPlanCostVer1 calculates the cost of the plan if it has not been calculated yet and returns the cost.
8990
func (p *PhysicalProjection) GetPlanCostVer1(taskType property.TaskType, option *optimizetrace.PlanCostOption) (float64, error) {
91+
intest.Assert(p.SCtx().GetSessionVars().CostModelVersion != 0)
9092
costFlag := option.CostFlag
9193
if p.PlanCostInit && !hasCostFlag(costFlag, costusage.CostFlagRecalculate) {
9294
return p.PlanCost, nil

pkg/sessionctx/variable/session.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,7 @@ func NewSessionVars(hctx HookContext) *SessionVars {
21892189
GroupConcatMaxLen: DefGroupConcatMaxLen,
21902190
EnableRedactLog: DefTiDBRedactLog,
21912191
EnableWindowFunction: DefEnableWindowFunction,
2192+
CostModelVersion: DefTiDBCostModelVer,
21922193
}
21932194
vars.status.Store(uint32(mysql.ServerStatusAutocommit))
21942195
vars.StmtCtx.ResourceGroupName = resourcegroup.DefaultResourceGroupName

0 commit comments

Comments
 (0)