Skip to content

Commit

Permalink
fiuxp
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 committed Dec 12, 2022
1 parent c4aa395 commit d6a2fc7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions planner/core/cbo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ func loadTableStats(fileName string, dom *domain.Domain) error {
return nil
}

func TestExplainCostTrace(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t (a int)")

tk.MustExec("set tidb_cost_model_version=2")
tk.MustQuery("explain format='cost_trace' select * from t").Check(testkit.Rows(
`TableReader_5 10000.00 177906.67 ((scan(10000*logrowsize(32)*tikv_scan_factor(40.7))) + (net(10000*rowsize(16)*tidb_kv_net_factor(3.96))))/15.00 root data:TableFullScan_4`,
`└─TableFullScan_4 10000.00 2035000.00 scan(10000*logrowsize(32)*tikv_scan_factor(40.7)) cop[tikv] table:t keep order:false, stats:pseudo`))

tk.MustExec("set tidb_cost_model_version=1")
tk.MustQuery("explain format='cost_trace' select * from t").Check(testkit.Rows(
// cost trace on model ver1 is not supported
`TableReader_5 10000.00 34418.00 N/A root data:TableFullScan_4`,
`└─TableFullScan_4 10000.00 435000.00 N/A cop[tikv] table:t keep order:false, stats:pseudo`,
))
}

func TestExplainAnalyze(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
Expand Down

0 comments on commit d6a2fc7

Please sign in to comment.