From 8a3be2e85c6855ccf08af86a0acd5eff93e7a9d9 Mon Sep 17 00:00:00 2001 From: qw4990 Date: Wed, 9 Nov 2022 14:47:48 +0800 Subject: [PATCH 1/5] fixup --- ddl/column_type_change_test.go | 2 +- executor/aggregate_test.go | 4 +- planner/core/cbo_test.go | 1 + planner/core/integration_test.go | 22 ++-- planner/core/physical_plan_test.go | 2 + planner/core/testdata/analyze_suite_out.json | 8 +- .../core/testdata/integration_suite_out.json | 101 ++++++++-------- planner/core/testdata/plan_suite_out.json | 16 +-- .../testdata/window_push_down_suite_out.json | 43 +++---- planner/core/window_push_down_test.go | 1 + server/conn_test.go | 1 + statistics/handle/handle_test.go | 2 +- statistics/selectivity_test.go | 1 + statistics/testdata/stats_suite_out.json | 108 +++++++++--------- util/ranger/ranger_test.go | 1 + util/ranger/testdata/ranger_suite_out.json | 18 +-- 16 files changed, 172 insertions(+), 159 deletions(-) diff --git a/ddl/column_type_change_test.go b/ddl/column_type_change_test.go index ae0adda97b99b..818d0714080f1 100644 --- a/ddl/column_type_change_test.go +++ b/ddl/column_type_change_test.go @@ -1946,7 +1946,7 @@ func TestChangeIntToBitWillPanicInBackfillIndexes(t *testing.T) { " KEY `idx3` (`a`,`b`),\n" + " KEY `idx4` (`a`,`b`,`c`)\n" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) - tk.MustQuery("select * from t").Check(testkit.Rows("\x13 1 1.00", "\x11 2 2.00")) + tk.MustQuery("select * from t").Sort().Check(testkit.Rows("\x11 2 2.00", "\x13 1 1.00")) } // Close issue #24584 diff --git a/executor/aggregate_test.go b/executor/aggregate_test.go index d29fa86d961fe..1868802d65d8d 100644 --- a/executor/aggregate_test.go +++ b/executor/aggregate_test.go @@ -1642,11 +1642,11 @@ func TestIssue26885(t *testing.T) { tk.MustExec("INSERT INTO t1 (c1) VALUES ('');") tk.MustExec("INSERT INTO t1 (c1) VALUES (0);") tk.MustQuery("select * from t1").Check(testkit.Rows("b", "", "a", "", "")) - tk.MustQuery("select c1 + 0 from t1").Check(testkit.Rows("3", "2", "1", "2", "0")) + tk.MustQuery("select c1 + 0 from t1").Sort().Check(testkit.Rows("0", "1", "2", "2", "3")) tk.MustQuery("SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1 order by c1;").Check(testkit.Rows("0 1", "1 1", "2 2", "3 1")) tk.MustExec("alter table t1 add index idx(c1); ") - tk.MustQuery("select c1 + 0 from t1").Check(testkit.Rows("3", "2", "1", "2", "0")) + tk.MustQuery("select c1 + 0 from t1").Sort().Check(testkit.Rows("0", "1", "2", "2", "3")) tk.MustQuery("SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1 order by c1;").Check(testkit.Rows("0 1", "1 1", "2 2", "3 1")) tk.MustExec(`DROP TABLE IF EXISTS t1;`) diff --git a/planner/core/cbo_test.go b/planner/core/cbo_test.go index d9c4dba7b676d..340c0e2830162 100644 --- a/planner/core/cbo_test.go +++ b/planner/core/cbo_test.go @@ -435,6 +435,7 @@ func TestCorrelatedEstimation(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("set sql_mode='STRICT_TRANS_TABLES'") // disable only full group by tk.MustExec("create table t(a int, b int, c int, index idx(c,b,a))") tk.MustExec("insert into t values(1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5), (6,6,6), (7,7,7), (8,8,8), (9,9,9),(10,10,10)") diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 889983c09f0ef..9f842f2b3c85b 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -1321,6 +1321,7 @@ func TestReadFromStorageHintAndIsolationRead(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists t, tt, ttt") tk.MustExec("create table t(a int, b int, index ia(a))") tk.MustExec("set @@session.tidb_isolation_read_engines=\"tikv\"") @@ -5698,6 +5699,7 @@ func TestOutputSkylinePruningInfo(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists t") tk.MustExec("create table t(a int, b int, c int, d int, e int, f int, g int, primary key (a), unique key c_d_e (c, d, e), unique key f (f), unique key f_g (f, g), key g (g))") @@ -5727,6 +5729,7 @@ func TestPreferRangeScanForUnsignedIntHandle(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists t") tk.MustExec("create table t(a int unsigned primary key, b int, c int, index idx_b(b))") tk.MustExec("insert into t values (1,2,3), (4,5,6), (7,8,9), (10,11,12), (13,14,15)") @@ -7089,6 +7092,7 @@ func TestAggWithJsonPushDownToTiFlash(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists t") tk.MustExec("create table t(a json);") tk.MustExec("insert into t values(null);") @@ -7110,26 +7114,26 @@ func TestAggWithJsonPushDownToTiFlash(t *testing.T) { } rows := [][]interface{}{ - {"HashAgg_6", "root", "funcs:avg(Column#4)->Column#3"}, + {"HashAgg_8", "root", "funcs:avg(Column#4)->Column#3"}, {"└─Projection_19", "root", "cast(test.t.a, double BINARY)->Column#4"}, - {" └─TableReader_12", "root", "data:TableFullScan_11"}, - {" └─TableFullScan_11", "cop[tiflash]", "keep order:false, stats:pseudo"}, + {" └─TableReader_14", "root", "data:TableFullScan_13"}, + {" └─TableFullScan_13", "cop[tiflash]", "keep order:false, stats:pseudo"}, } tk.MustQuery("explain select avg(a) from t;").CheckAt([]int{0, 2, 4}, rows) rows = [][]interface{}{ - {"HashAgg_6", "root", "funcs:sum(Column#4)->Column#3"}, + {"HashAgg_8", "root", "funcs:sum(Column#4)->Column#3"}, {"└─Projection_19", "root", "cast(test.t.a, double BINARY)->Column#4"}, - {" └─TableReader_12", "root", "data:TableFullScan_11"}, - {" └─TableFullScan_11", "cop[tiflash]", "keep order:false, stats:pseudo"}, + {" └─TableReader_14", "root", "data:TableFullScan_13"}, + {" └─TableFullScan_13", "cop[tiflash]", "keep order:false, stats:pseudo"}, } tk.MustQuery("explain select sum(a) from t;").CheckAt([]int{0, 2, 4}, rows) rows = [][]interface{}{ - {"HashAgg_6", "root", "funcs:group_concat(Column#4 separator \",\")->Column#3"}, + {"HashAgg_8", "root", "funcs:group_concat(Column#4 separator \",\")->Column#3"}, {"└─Projection_13", "root", "cast(test.t.a, var_string(4294967295))->Column#4"}, - {" └─TableReader_10", "root", "data:TableFullScan_9"}, - {" └─TableFullScan_9", "cop[tiflash]", "keep order:false, stats:pseudo"}, + {" └─TableReader_12", "root", "data:TableFullScan_11"}, + {" └─TableFullScan_11", "cop[tiflash]", "keep order:false, stats:pseudo"}, } tk.MustQuery("explain select /*+ hash_agg() */ group_concat(a) from t;").CheckAt([]int{0, 2, 4}, rows) } diff --git a/planner/core/physical_plan_test.go b/planner/core/physical_plan_test.go index dece0b960bf21..70ce502d7a5df 100644 --- a/planner/core/physical_plan_test.go +++ b/planner/core/physical_plan_test.go @@ -407,6 +407,7 @@ func TestDAGPlanBuilderAgg(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("set sql_mode='STRICT_TRANS_TABLES'") // disable only full group by sessionVars := tk.Session().GetSessionVars() sessionVars.SetHashAggFinalConcurrency(1) @@ -1766,6 +1767,7 @@ func TestIndexJoinHint(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec(`drop table if exists test.t1, test.t2, test.t;`) tk.MustExec(`create table test.t1(a bigint, b bigint, index idx_a(a), index idx_b(b));`) tk.MustExec(`create table test.t2(a bigint, b bigint, index idx_a(a), index idx_b(b));`) diff --git a/planner/core/testdata/analyze_suite_out.json b/planner/core/testdata/analyze_suite_out.json index 750fc736a7f6e..e19c4bb0596b3 100644 --- a/planner/core/testdata/analyze_suite_out.json +++ b/planner/core/testdata/analyze_suite_out.json @@ -384,12 +384,12 @@ " │ └─TableFullScan 10.00 cop[tikv] table:t keep order:false", " └─StreamAgg(Probe) 10.00 root funcs:count(1)->Column#21", " └─HashJoin 10.00 root inner join, equal:[eq(test.t.a, test.t.a)]", - " ├─TableReader(Build) 10.00 root data:Selection", + " ├─IndexReader(Build) 10.00 root index:Selection", " │ └─Selection 10.00 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a))", - " │ └─TableFullScan 100.00 cop[tikv] table:t1 keep order:false", - " └─TableReader(Probe) 10.00 root data:Selection", + " │ └─IndexFullScan 100.00 cop[tikv] table:t1, index:idx(c, b, a) keep order:false", + " └─IndexReader(Probe) 10.00 root index:Selection", " └─Selection 10.00 cop[tikv] eq(test.t.a, test.t.a), not(isnull(test.t.a))", - " └─TableFullScan 100.00 cop[tikv] table:s keep order:false" + " └─IndexFullScan 100.00 cop[tikv] table:s, index:idx(c, b, a) keep order:false" ], [ "Projection 10.00 root Column#13", diff --git a/planner/core/testdata/integration_suite_out.json b/planner/core/testdata/integration_suite_out.json index e223d6604e3f1..c042cde23ab44 100644 --- a/planner/core/testdata/integration_suite_out.json +++ b/planner/core/testdata/integration_suite_out.json @@ -1964,21 +1964,20 @@ { "SQL": "select * from t where a > 1 order by f", "Plan": [ - "IndexLookUp_14 3333.33 136747.00 root ", - "├─Selection_13(Build) 3333.33 585000.00 cop[tikv] gt(test.t.a, 1)", - "│ └─IndexFullScan_11 10000.00 555000.00 cop[tikv] table:t, index:f(f) keep order:true, stats:pseudo", - "└─TableRowIDScan_12(Probe) 3333.33 370000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "Sort_5 3333.33 2146348.14 root test.t.f", + "└─TableReader_9 3333.33 160128.74 root data:TableRangeScan_8", + " └─TableRangeScan_8 3333.33 923531.15 cop[tikv] table:t range:(1,+inf], keep order:false, stats:pseudo" ], "Warnings": [ - "Note 1105 [t,f,f_g] remain after pruning paths for t given Prop{SortItems: [{test.t.f asc}], TaskTp: rootTask}" + "Note 1105 [t] remain after pruning paths for t given Prop{SortItems: [], TaskTp: rootTask}" ] }, { "SQL": "select * from t where f > 1", "Plan": [ - "IndexLookUp_10 3333.33 86674.83 root ", - "├─IndexRangeScan_8(Build) 3333.33 185000.00 cop[tikv] table:t, index:f(f) range:(1,+inf], keep order:false, stats:pseudo", - "└─TableRowIDScan_9(Probe) 3333.33 370000.00 cop[tikv] table:t keep order:false, stats:pseudo" + "TableReader_7 3333.33 316532.90 root data:Selection_6", + "└─Selection_6 3333.33 3269593.45 cop[tikv] gt(test.t.f, 1)", + " └─TableFullScan_5 10000.00 2770593.45 cop[tikv] table:t keep order:false, stats:pseudo" ], "Warnings": [ "Note 1105 [t,f,f_g] remain after pruning paths for t given Prop{SortItems: [], TaskTp: rootTask}" @@ -1987,8 +1986,8 @@ { "SQL": "select f from t where f > 1", "Plan": [ - "IndexReader_6 3333.33 11140.22 root index:IndexRangeScan_5", - "└─IndexRangeScan_5 3333.33 140000.00 cop[tikv] table:t, index:f(f) range:(1,+inf], keep order:false, stats:pseudo" + "IndexReader_6 3333.33 50257.78 root index:IndexRangeScan_5", + "└─IndexRangeScan_5 3333.33 542666.67 cop[tikv] table:t, index:f(f) range:(1,+inf], keep order:false, stats:pseudo" ], "Warnings": [ "Note 1105 [f,f_g] remain after pruning paths for t given Prop{SortItems: [], TaskTp: rootTask}" @@ -1997,10 +1996,10 @@ { "SQL": "select * from t where f > 3 and g = 5", "Plan": [ - "IndexLookUp_15 3.33 206.74 root ", - "├─IndexRangeScan_12(Build) 10.00 570.00 cop[tikv] table:t, index:g(g) range:[5,5], keep order:false, stats:pseudo", - "└─Selection_14(Probe) 3.33 1140.00 cop[tikv] gt(test.t.f, 3)", - " └─TableRowIDScan_13 10.00 1110.00 cop[tikv] table:t keep order:false, stats:pseudo" + "IndexLookUp_15 3.33 19551.99 root ", + "├─IndexRangeScan_12(Build) 10.00 2035.00 cop[tikv] table:t, index:g(g) range:[5,5], keep order:false, stats:pseudo", + "└─Selection_14(Probe) 3.33 3269.59 cop[tikv] gt(test.t.f, 3)", + " └─TableRowIDScan_13 10.00 2770.59 cop[tikv] table:t keep order:false, stats:pseudo" ], "Warnings": [ "Note 1105 [t,f_g,g] remain after pruning paths for t given Prop{SortItems: [], TaskTp: rootTask}" @@ -2009,10 +2008,10 @@ { "SQL": "select * from t where g = 5 order by f", "Plan": [ - "Sort_5 10.00 353.68 root test.t.f", - "└─IndexLookUp_13 10.00 230.01 root ", - " ├─IndexRangeScan_11(Build) 10.00 570.00 cop[tikv] table:t, index:g(g) range:[5,5], keep order:false, stats:pseudo", - " └─TableRowIDScan_12(Probe) 10.00 1110.00 cop[tikv] table:t keep order:false, stats:pseudo" + "Sort_5 10.00 21321.97 root test.t.f", + "└─IndexLookUp_13 10.00 19545.34 root ", + " ├─IndexRangeScan_11(Build) 10.00 2035.00 cop[tikv] table:t, index:g(g) range:[5,5], keep order:false, stats:pseudo", + " └─TableRowIDScan_12(Probe) 10.00 2770.59 cop[tikv] table:t keep order:false, stats:pseudo" ], "Warnings": [ "Note 1105 [t,g] remain after pruning paths for t given Prop{SortItems: [], TaskTp: rootTask}" @@ -2021,10 +2020,10 @@ { "SQL": "select * from t where d = 3 order by c, e", "Plan": [ - "IndexLookUp_15 10.00 57222.78 root ", - "├─Selection_14(Build) 10.00 855000.00 cop[tikv] eq(test.t.d, 3)", - "│ └─IndexFullScan_12 10000.00 825000.00 cop[tikv] table:t, index:c_d_e(c, d, e) keep order:true, stats:pseudo", - "└─TableRowIDScan_13(Probe) 10.00 1110.00 cop[tikv] table:t keep order:false, stats:pseudo" + "IndexLookUp_15 10.00 215519.24 root ", + "├─Selection_14(Build) 10.00 2941000.00 cop[tikv] eq(test.t.d, 3)", + "│ └─IndexFullScan_12 10000.00 2442000.00 cop[tikv] table:t, index:c_d_e(c, d, e) keep order:true, stats:pseudo", + "└─TableRowIDScan_13(Probe) 10.00 2770.59 cop[tikv] table:t keep order:false, stats:pseudo" ], "Warnings": [ "Note 1105 [t,c_d_e] remain after pruning paths for t given Prop{SortItems: [{test.t.c asc} {test.t.e asc}], TaskTp: rootTask}" @@ -2043,31 +2042,31 @@ { "SQL": "explain format = 'verbose' select * from t where b > 5", "Plan": [ - "TableReader_7 3.00 19.21 root data:Selection_6", - "└─Selection_6 3.00 195.00 cop[tikv] gt(test.t.b, 5)", - " └─TableFullScan_5 5.00 180.00 cop[tikv] table:t keep order:false" + "TableReader_7 3.00 130.42 root data:Selection_6", + "└─Selection_6 3.00 1386.04 cop[tikv] gt(test.t.b, 5)", + " └─TableFullScan_5 5.00 1136.54 cop[tikv] table:t keep order:false" ], "Warnings": null }, { "SQL": "explain format = 'verbose' select * from t where b = 6 order by a limit 1", "Plan": [ - "Limit_11 0.00 14.33 root offset:0, count:1", - "└─TableReader_24 0.00 14.33 root data:Limit_23", - " └─Limit_23 0.00 195.00 cop[tikv] offset:0, count:1", - " └─Selection_22 0.00 195.00 cop[tikv] eq(test.t.b, 6)", - " └─TableFullScan_21 5.00 180.00 cop[tikv] table:t keep order:true" + "Limit_11 0.00 92.40 root offset:0, count:1", + "└─TableReader_24 0.00 92.40 root data:Limit_23", + " └─Limit_23 0.00 1386.04 cop[tikv] offset:0, count:1", + " └─Selection_22 0.00 1386.04 cop[tikv] eq(test.t.b, 6)", + " └─TableFullScan_21 5.00 1136.54 cop[tikv] table:t keep order:true" ], "Warnings": null }, { "SQL": "explain format = 'verbose' select * from t where b = 6 limit 1", "Plan": [ - "Limit_8 0.00 14.33 root offset:0, count:1", - "└─TableReader_13 0.00 14.33 root data:Limit_12", - " └─Limit_12 0.00 195.00 cop[tikv] offset:0, count:1", - " └─Selection_11 0.00 195.00 cop[tikv] eq(test.t.b, 6)", - " └─TableFullScan_10 5.00 180.00 cop[tikv] table:t keep order:false" + "Limit_8 0.00 92.40 root offset:0, count:1", + "└─TableReader_13 0.00 92.40 root data:Limit_12", + " └─Limit_12 0.00 1386.04 cop[tikv] offset:0, count:1", + " └─Selection_11 0.00 1386.04 cop[tikv] eq(test.t.b, 6)", + " └─TableFullScan_10 5.00 1136.54 cop[tikv] table:t keep order:false" ], "Warnings": null }, @@ -2079,9 +2078,9 @@ { "SQL": "explain format = 'verbose' select * from t where b > 5", "Plan": [ - "IndexLookUp_7 3.00 57.91 root ", - "├─IndexRangeScan_5(Build) 3.00 171.00 cop[tikv] table:t, index:idx_b(b) range:(5,+inf], keep order:false", - "└─TableRowIDScan_6(Probe) 3.00 108.00 cop[tikv] table:t keep order:false" + "IndexLookUp_7 3.00 5856.46 root ", + "├─IndexRangeScan_5(Build) 3.00 610.50 cop[tikv] table:t, index:idx_b(b) range:(5,+inf], keep order:false", + "└─TableRowIDScan_6(Probe) 3.00 681.92 cop[tikv] table:t keep order:false" ], "Warnings": [ "Note 1105 [idx_b] remain after pruning paths for t given Prop{SortItems: [], TaskTp: rootTask}" @@ -2090,9 +2089,9 @@ { "SQL": "explain format = 'verbose' select * from t where b = 6 order by a limit 1", "Plan": [ - "TopN_9 0.00 19.34 root test.t.a, offset:0, count:1", - "└─IndexLookUp_16 0.00 19.33 root ", - " ├─TopN_15(Build) 0.00 0.00 cop[tikv] test.t.a, offset:0, count:1", + "TopN_9 0.00 1925.01 root test.t.a, offset:0, count:1", + "└─IndexLookUp_16 0.00 1920.21 root ", + " ├─TopN_15(Build) 0.00 3.20 cop[tikv] test.t.a, offset:0, count:1", " │ └─IndexRangeScan_13 0.00 0.00 cop[tikv] table:t, index:idx_b(b) range:[6,6], keep order:false", " └─TableRowIDScan_14(Probe) 0.00 0.00 cop[tikv] table:t keep order:false" ], @@ -2103,7 +2102,7 @@ { "SQL": "explain format = 'verbose' select * from t where b = 6 limit 1", "Plan": [ - "IndexLookUp_13 0.00 19.33 root limit embedded(offset:0, count:1)", + "IndexLookUp_13 0.00 1152.00 root limit embedded(offset:0, count:1)", "├─Limit_12(Build) 0.00 0.00 cop[tikv] offset:0, count:1", "│ └─IndexRangeScan_10 0.00 0.00 cop[tikv] table:t, index:idx_b(b) range:[6,6], keep order:false", "└─TableRowIDScan_11(Probe) 0.00 0.00 cop[tikv] table:t keep order:false" @@ -4314,9 +4313,9 @@ { "SQL": "desc format = 'brief' select /*+ read_from_storage(tikv[t], tiflash[t]) */ avg(a) from t", "Plan": [ - "StreamAgg 1.00 root funcs:avg(Column#7, Column#8)->Column#4", - "└─IndexReader 1.00 root index:StreamAgg", - " └─StreamAgg 1.00 cop[tikv] funcs:count(test.t.a)->Column#7, funcs:sum(test.t.a)->Column#8", + "HashAgg 1.00 root funcs:avg(Column#5, Column#6)->Column#4", + "└─IndexReader 1.00 root index:HashAgg", + " └─HashAgg 1.00 cop[tikv] funcs:count(test.t.a)->Column#5, funcs:sum(test.t.a)->Column#6", " └─IndexFullScan 10000.00 cop[tikv] table:t, index:ia(a) keep order:false, stats:pseudo" ], "Warn": [ @@ -4326,9 +4325,9 @@ { "SQL": "desc format = 'brief' select /*+ read_from_storage(tikv[t]) */ avg(a) from t", "Plan": [ - "StreamAgg 1.00 root funcs:avg(Column#7, Column#8)->Column#4", - "└─IndexReader 1.00 root index:StreamAgg", - " └─StreamAgg 1.00 cop[tikv] funcs:count(test.t.a)->Column#7, funcs:sum(test.t.a)->Column#8", + "HashAgg 1.00 root funcs:avg(Column#5, Column#6)->Column#4", + "└─IndexReader 1.00 root index:HashAgg", + " └─HashAgg 1.00 cop[tikv] funcs:count(test.t.a)->Column#5, funcs:sum(test.t.a)->Column#6", " └─IndexFullScan 10000.00 cop[tikv] table:t, index:ia(a) keep order:false, stats:pseudo" ], "Warn": null @@ -4336,9 +4335,9 @@ { "SQL": "desc format = 'brief' select /*+ read_from_storage(tiflash[t]) */ avg(a) from t", "Plan": [ - "StreamAgg 1.00 root funcs:avg(Column#7, Column#8)->Column#4", - "└─IndexReader 1.00 root index:StreamAgg", - " └─StreamAgg 1.00 cop[tikv] funcs:count(test.t.a)->Column#7, funcs:sum(test.t.a)->Column#8", + "HashAgg 1.00 root funcs:avg(Column#5, Column#6)->Column#4", + "└─IndexReader 1.00 root index:HashAgg", + " └─HashAgg 1.00 cop[tikv] funcs:count(test.t.a)->Column#5, funcs:sum(test.t.a)->Column#6", " └─IndexFullScan 10000.00 cop[tikv] table:t, index:ia(a) keep order:false, stats:pseudo" ], "Warn": [ diff --git a/planner/core/testdata/plan_suite_out.json b/planner/core/testdata/plan_suite_out.json index adbd39cf82e7e..e914b03ec72e2 100644 --- a/planner/core/testdata/plan_suite_out.json +++ b/planner/core/testdata/plan_suite_out.json @@ -935,7 +935,7 @@ "Cases": [ { "SQL": "select distinct b from t", - "Best": "TableReader(Table(t))->HashAgg" + "Best": "TableReader(Table(t)->HashAgg)->HashAgg" }, { "SQL": "select count(*) from (select * from t order by b) t group by b", @@ -963,11 +963,11 @@ }, { "SQL": "select sum(e), avg(e + c) from t where c = 1 group by e", - "Best": "IndexReader(Index(t.c_d_e)[[1,1]]->HashAgg)->HashAgg" + "Best": "IndexReader(Index(t.c_d_e)[[1,1]])->Projection->HashAgg" }, { "SQL": "select sum(e), avg(b + c) from t where c = 1 and e = 1 group by d", - "Best": "IndexLookUp(Index(t.c_d_e)[[1,1]]->Sel([eq(test.t.e, 1)]), Table(t))->Projection->HashAgg" + "Best": "IndexLookUp(Index(t.c_d_e)[[1,1]]->Sel([eq(test.t.e, 1)]), Table(t))->Projection->Projection->StreamAgg" }, { "SQL": "select sum(e), avg(b + c) from t where c = 1 and b = 1", @@ -975,11 +975,11 @@ }, { "SQL": "select sum(e) as k, avg(b + c) from t where c = 1 and b = 1 and e = 1 group by d order by k", - "Best": "IndexLookUp(Index(t.c_d_e)[[1,1]]->Sel([eq(test.t.e, 1)]), Table(t)->Sel([eq(test.t.b, 1)]))->Projection->HashAgg->Sort" + "Best": "IndexLookUp(Index(t.c_d_e)[[1,1]]->Sel([eq(test.t.e, 1)]), Table(t)->Sel([eq(test.t.b, 1)]))->Projection->Projection->StreamAgg->Sort" }, { "SQL": "select sum(e) as k, avg(b + c) from t where c = 1 and b = 1 and e = 1 group by c order by k", - "Best": "IndexLookUp(Index(t.c_d_e)[[1,1]]->Sel([eq(test.t.e, 1)]), Table(t)->Sel([eq(test.t.b, 1)]))->Projection->HashAgg->Sort" + "Best": "IndexLookUp(Index(t.c_d_e)[[1,1]]->Sel([eq(test.t.e, 1)]), Table(t)->Sel([eq(test.t.b, 1)]))->Projection->Projection->StreamAgg->Sort" }, { "SQL": "select sum(to_base64(e)) from t where c = 1", @@ -987,7 +987,7 @@ }, { "SQL": "select (select count(1) k from t s where s.a = t.a having k != 0) from t", - "Best": "LeftHashJoin{IndexReader(Index(t.f)[[NULL,+inf]])->IndexReader(Index(t.f)[[NULL,+inf]])->Projection}(test.t.a,test.t.a)->Projection" + "Best": "MergeLeftOuterJoin{TableReader(Table(t))->TableReader(Table(t))->Projection}(test.t.a,test.t.a)->Projection" }, { "SQL": "select sum(to_base64(e)) from t group by e,d,c order by c", @@ -1609,11 +1609,11 @@ }, { "SQL": "select /*+ inl_merge_join(t2) */ t1.a, t2.a from t t1 left join t t2 use index(g_2) on t1.g=t2.g", - "Plan": "IndexMergeJoin{IndexReader(Index(t.g_3)[[NULL,+inf]])->IndexReader(Index(t.g_2)[[NULL,NULL]]->Sel([not(isnull(test.t.g))]))}(test.t.g,test.t.g)" + "Plan": "IndexMergeJoin{IndexReader(Index(t.g_2)[[NULL,+inf]])->IndexReader(Index(t.g_2)[[NULL,NULL]]->Sel([not(isnull(test.t.g))]))}(test.t.g,test.t.g)" }, { "SQL": "select /*+inl_merge_join(t2)*/ t1.a, t2.a from t t1 left join t t2 use index(g_2) on t1.g=t2.g order by t1.a", - "Plan": "IndexMergeJoin{IndexReader(Index(t.g_3)[[NULL,+inf]])->IndexReader(Index(t.g_2)[[NULL,NULL]]->Sel([not(isnull(test.t.g))]))}(test.t.g,test.t.g)->Sort" + "Plan": "IndexMergeJoin{IndexReader(Index(t.g_2)[[NULL,+inf]])->IndexReader(Index(t.g_2)[[NULL,NULL]]->Sel([not(isnull(test.t.g))]))}(test.t.g,test.t.g)->Sort" } ] }, diff --git a/planner/core/testdata/window_push_down_suite_out.json b/planner/core/testdata/window_push_down_suite_out.json index e4b3aa37c09a6..0b587eb83ce39 100644 --- a/planner/core/testdata/window_push_down_suite_out.json +++ b/planner/core/testdata/window_push_down_suite_out.json @@ -343,11 +343,12 @@ "TableReader_84 8000.00 root data:ExchangeSender_83", "└─ExchangeSender_83 8000.00 mpp[tiflash] ExchangeType: PassThrough", " └─Window_82 8000.00 mpp[tiflash] row_number()->Column#7 over(rows between current row and current row)", - " └─Projection_19 8000.00 mpp[tiflash] Column#5", - " └─HashAgg_12 8000.00 mpp[tiflash] group by:test.employee.deptid, funcs:count(test.employee.empid)->Column#5", - " └─ExchangeReceiver_18 10000.00 mpp[tiflash] ", - " └─ExchangeSender_17 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.employee.deptid, collate: binary]", - " └─TableFullScan_16 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" + " └─Projection_21 8000.00 mpp[tiflash] Column#5", + " └─HashAgg_22 8000.00 mpp[tiflash] group by:test.employee.deptid, funcs:sum(Column#8)->Column#5", + " └─ExchangeReceiver_24 8000.00 mpp[tiflash] ", + " └─ExchangeSender_23 8000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.employee.deptid, collate: binary]", + " └─HashAgg_13 8000.00 mpp[tiflash] group by:test.employee.deptid, funcs:count(test.employee.empid)->Column#8", + " └─TableFullScan_20 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" ], "Warn": null }, @@ -378,12 +379,13 @@ "TableReader_61 8000.00 root data:ExchangeSender_60", "└─ExchangeSender_60 8000.00 mpp[tiflash] ExchangeType: PassThrough", " └─Window_59 8000.00 mpp[tiflash] row_number()->Column#7 over(partition by test.employee.deptid rows between current row and current row)", - " └─Sort_18 8000.00 mpp[tiflash] test.employee.deptid", - " └─Projection_17 8000.00 mpp[tiflash] Column#5, test.employee.deptid", - " └─HashAgg_12 8000.00 mpp[tiflash] group by:test.employee.deptid, funcs:count(test.employee.empid)->Column#5, funcs:firstrow(test.employee.deptid)->test.employee.deptid", - " └─ExchangeReceiver_16 10000.00 mpp[tiflash] ", - " └─ExchangeSender_15 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.employee.deptid, collate: binary]", - " └─TableFullScan_14 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" + " └─Sort_24 8000.00 mpp[tiflash] test.employee.deptid", + " └─Projection_20 8000.00 mpp[tiflash] Column#5, test.employee.deptid", + " └─HashAgg_21 8000.00 mpp[tiflash] group by:test.employee.deptid, funcs:sum(Column#8)->Column#5, funcs:firstrow(test.employee.deptid)->test.employee.deptid", + " └─ExchangeReceiver_23 8000.00 mpp[tiflash] ", + " └─ExchangeSender_22 8000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.employee.deptid, collate: binary]", + " └─HashAgg_13 8000.00 mpp[tiflash] group by:test.employee.deptid, funcs:count(test.employee.empid)->Column#8", + " └─TableFullScan_19 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" ], "Warn": null }, @@ -441,15 +443,16 @@ "Plan": [ "TableReader_54 10000.00 root data:ExchangeSender_53", "└─ExchangeSender_53 10000.00 mpp[tiflash] ExchangeType: PassThrough", - " └─Projection_48 10000.00 mpp[tiflash] Column#7", - " └─HashAgg_46 10000.00 mpp[tiflash] group by:Column#6, funcs:count(test.employee.empid)->Column#7", - " └─ExchangeReceiver_32 10000.00 mpp[tiflash] ", - " └─ExchangeSender_31 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: Column#6, collate: binary]", - " └─Window_30 10000.00 mpp[tiflash] row_number()->Column#6 over(partition by test.employee.deptid rows between current row and current row), stream_count: 8", - " └─Sort_21 10000.00 mpp[tiflash] test.employee.deptid, stream_count: 8", - " └─ExchangeReceiver_20 10000.00 mpp[tiflash] stream_count: 8", - " └─ExchangeSender_19 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.employee.deptid, collate: binary], stream_count: 8", - " └─TableFullScan_18 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" + " └─Projection_49 10000.00 mpp[tiflash] Column#7", + " └─HashAgg_50 10000.00 mpp[tiflash] group by:Column#6, funcs:sum(Column#10)->Column#7", + " └─ExchangeReceiver_52 10000.00 mpp[tiflash] ", + " └─ExchangeSender_51 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: Column#6, collate: binary]", + " └─HashAgg_47 10000.00 mpp[tiflash] group by:Column#6, funcs:count(test.employee.empid)->Column#10", + " └─Window_36 10000.00 mpp[tiflash] row_number()->Column#6 over(partition by test.employee.deptid rows between current row and current row), stream_count: 8", + " └─Sort_21 10000.00 mpp[tiflash] test.employee.deptid, stream_count: 8", + " └─ExchangeReceiver_20 10000.00 mpp[tiflash] stream_count: 8", + " └─ExchangeSender_19 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.employee.deptid, collate: binary], stream_count: 8", + " └─TableFullScan_18 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo" ], "Warn": null }, diff --git a/planner/core/window_push_down_test.go b/planner/core/window_push_down_test.go index 599fe113ff1c5..0d8538fa19ca0 100644 --- a/planner/core/window_push_down_test.go +++ b/planner/core/window_push_down_test.go @@ -110,6 +110,7 @@ func TestWindowPlanWithOtherOperators(t *testing.T) { dom := domain.GetDomain(tk.Session()) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists employee") tk.MustExec("create table employee (empid int, deptid int, salary decimal(10,2))") SetTiFlashReplica(t, dom, "test", "employee") diff --git a/server/conn_test.go b/server/conn_test.go index 7ac9d4f9a6774..84db98f9e1827 100644 --- a/server/conn_test.go +++ b/server/conn_test.go @@ -858,6 +858,7 @@ func TestTiFlashFallback(t *testing.T) { cc.setCtx(&TiDBContext{Session: tk.Session(), stmts: make(map[int]*TiDBStatement)}) tk.MustExec("drop table if exists t") + tk.MustExec("set tidb_cost_model_version=1") tk.MustExec("create table t(a int not null primary key, b int not null)") tk.MustExec("alter table t set tiflash replica 1") tb := external.GetTableByName(t, tk, "test", "t") diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index f8f73b933bd9a..28c6379138edd 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -2264,7 +2264,7 @@ func TestIndexUsageInformation(t *testing.T) { tk.MustQuery("select b from t_idx where b=0") err = do.StatsHandle().DumpIndexUsageToKV() require.NoError(t, err) - tk.MustQuery(querySQL).Check(testkit.Rows( + tk.MustQuery(querySQL).Sort().Check(testkit.Rows( "test t_idx idx_a 3 2", "test t_idx idx_b 2 2", )) diff --git a/statistics/selectivity_test.go b/statistics/selectivity_test.go index 26e79c93cc5fd..f0dad37f7cac8 100644 --- a/statistics/selectivity_test.go +++ b/statistics/selectivity_test.go @@ -299,6 +299,7 @@ func TestStatsVer2(t *testing.T) { store := testkit.CreateMockStore(t) testKit := testkit.NewTestKit(t, store) testKit.MustExec("use test") + testKit.MustExec("set tidb_cost_model_version=2") testKit.MustExec("set tidb_analyze_version=2") testKit.MustExec("drop table if exists tint") diff --git a/statistics/testdata/stats_suite_out.json b/statistics/testdata/stats_suite_out.json index d07b336ccbfbd..a78fafe87ade9 100644 --- a/statistics/testdata/stats_suite_out.json +++ b/statistics/testdata/stats_suite_out.json @@ -170,34 +170,34 @@ " └─TableFullScan_5 8.00 cop[tikv] table:tint keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdouble, index:singular(a) range:[1,1], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdouble keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdouble.a, 1)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdouble keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdouble, index:singular(a) range:[4,4], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdouble keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdouble.a, 4)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdouble keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdouble, index:singular(a) range:[8,8], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdouble keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdouble.a, 8)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdouble keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdecimal, index:singular(a) range:[1.00000000000000000000,1.00000000000000000000], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdecimal keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdecimal.a, 1)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdecimal keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdecimal, index:singular(a) range:[4.00000000000000000000,4.00000000000000000000], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdecimal keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdecimal.a, 4)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdecimal keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdecimal, index:singular(a) range:[8.00000000000000000000,8.00000000000000000000], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdecimal keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdecimal.a, 8)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdecimal keep order:false" ], [ "TableReader_7 1.00 root data:Selection_6", @@ -260,34 +260,34 @@ " └─TableFullScan_5 8.00 cop[tikv] table:tint keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdouble, index:multi(b, c) range:[1 1,1 1], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdouble keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdouble.b, 1), eq(test.tdouble.c, 1)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdouble keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdouble, index:multi(b, c) range:[4 4,4 4], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdouble keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdouble.b, 4), eq(test.tdouble.c, 4)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdouble keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdouble, index:multi(b, c) range:[8 8,8 8], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdouble keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdouble.b, 8), eq(test.tdouble.c, 8)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdouble keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdecimal, index:multi(b, c) range:[1.00000000000000000000 1.00000000000000000000,1.00000000000000000000 1.00000000000000000000], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdecimal keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdecimal.b, 1), eq(test.tdecimal.c, 1)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdecimal keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdecimal, index:multi(b, c) range:[4.00000000000000000000 4.00000000000000000000,4.00000000000000000000 4.00000000000000000000], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdecimal keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdecimal.b, 4), eq(test.tdecimal.c, 4)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdecimal keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdecimal, index:multi(b, c) range:[8.00000000000000000000 8.00000000000000000000,8.00000000000000000000 8.00000000000000000000], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdecimal keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdecimal.b, 8), eq(test.tdecimal.c, 8)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdecimal keep order:false" ], [ "TableReader_7 1.00 root data:Selection_6", @@ -335,34 +335,34 @@ " └─TableFullScan_5 8.00 cop[tikv] table:tint keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdouble, index:multi(b, c) range:[1,1], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdouble keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdouble.b, 1)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdouble keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdouble, index:multi(b, c) range:[4,4], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdouble keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdouble.b, 4)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdouble keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdouble, index:multi(b, c) range:[8,8], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdouble keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdouble.b, 8)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdouble keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdecimal, index:multi(b, c) range:[1.00000000000000000000,1.00000000000000000000], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdecimal keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdecimal.b, 1)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdecimal keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdecimal, index:multi(b, c) range:[4.00000000000000000000,4.00000000000000000000], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdecimal keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdecimal.b, 4)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdecimal keep order:false" ], [ - "IndexLookUp_10 1.00 root ", - "├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:tdecimal, index:multi(b, c) range:[8.00000000000000000000,8.00000000000000000000], keep order:false", - "└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:tdecimal keep order:false" + "TableReader_7 1.00 root data:Selection_6", + "└─Selection_6 1.00 cop[tikv] eq(test.tdecimal.b, 8)", + " └─TableFullScan_5 8.00 cop[tikv] table:tdecimal keep order:false" ], [ "TableReader_7 1.00 root data:Selection_6", diff --git a/util/ranger/ranger_test.go b/util/ranger/ranger_test.go index 230252bc8489d..522494f447e04 100644 --- a/util/ranger/ranger_test.go +++ b/util/ranger/ranger_test.go @@ -891,6 +891,7 @@ func TestIndexStringIsTrueRange(t *testing.T) { testKit := testkit.NewTestKit(t, store) testKit.MustExec("use test") + testKit.MustExec("set tidb_cost_model_version=2") testKit.MustExec("drop table if exists t0") testKit.MustExec("CREATE TABLE t0(c0 TEXT(10));") testKit.MustExec("INSERT INTO t0(c0) VALUES (1);") diff --git a/util/ranger/testdata/ranger_suite_out.json b/util/ranger/testdata/ranger_suite_out.json index 174731cac0827..e4de18e162c7b 100644 --- a/util/ranger/testdata/ranger_suite_out.json +++ b/util/ranger/testdata/ranger_suite_out.json @@ -32,9 +32,9 @@ { "SQL": "explain format = 'brief' select * from t0 where c0", "Result": [ - "TableReader 0.80 root data:Selection", - "└─Selection 0.80 cop[tikv] test.t0.c0", - " └─TableFullScan 1.00 cop[tikv] table:t0 keep order:false" + "IndexReader 1.00 root index:Selection", + "└─Selection 1.00 cop[tikv] test.t0.c0", + " └─IndexFullScan 1.00 cop[tikv] table:t0, index:i0(c0) keep order:false" ] }, { @@ -56,17 +56,17 @@ { "SQL": "explain format = 'brief' select * from t0 where c0 is true", "Result": [ - "TableReader 0.80 root data:Selection", - "└─Selection 0.80 cop[tikv] istrue(cast(test.t0.c0, double BINARY))", - " └─TableFullScan 1.00 cop[tikv] table:t0 keep order:false" + "IndexReader 1.00 root index:Selection", + "└─Selection 1.00 cop[tikv] istrue(cast(test.t0.c0, double BINARY))", + " └─IndexFullScan 1.00 cop[tikv] table:t0, index:i0(c0) keep order:false" ] }, { "SQL": "explain format = 'brief' select * from t0 where c0 is false", "Result": [ - "TableReader 0.80 root data:Selection", - "└─Selection 0.80 cop[tikv] isfalse(cast(test.t0.c0, double BINARY))", - " └─TableFullScan 1.00 cop[tikv] table:t0 keep order:false" + "IndexReader 1.00 root index:Selection", + "└─Selection 1.00 cop[tikv] isfalse(cast(test.t0.c0, double BINARY))", + " └─IndexFullScan 1.00 cop[tikv] table:t0, index:i0(c0) keep order:false" ] }, { From 60dde93bf8258ce11db74ec5b28cddec54bb28a8 Mon Sep 17 00:00:00 2001 From: qw4990 Date: Wed, 9 Nov 2022 16:44:53 +0800 Subject: [PATCH 2/5] fixup --- planner/core/physical_plan_test.go | 1 + planner/core/plan_cost_ver2.go | 4 ++-- planner/core/testdata/plan_suite_out.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/planner/core/physical_plan_test.go b/planner/core/physical_plan_test.go index 70ce502d7a5df..d6ad45da76ee1 100644 --- a/planner/core/physical_plan_test.go +++ b/planner/core/physical_plan_test.go @@ -444,6 +444,7 @@ func TestRefine(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") var input []string var output []struct { diff --git a/planner/core/plan_cost_ver2.go b/planner/core/plan_cost_ver2.go index b717b8580d2b5..0f4c936fa4e46 100644 --- a/planner/core/plan_cost_ver2.go +++ b/planner/core/plan_cost_ver2.go @@ -161,7 +161,7 @@ func (p *PhysicalIndexReader) getPlanCostVer2(taskType property.TaskType, option } rows := getCardinality(p.indexPlan, option.CostFlag) - rowSize := getAvgRowSize(p.indexPlan.Stats(), p.indexPlan.Schema().Columns) + rowSize := getAvgRowSize(p.stats, p.schema.Columns) netFactor := getTaskNetFactorVer2(p, taskType) concurrency := float64(p.ctx.GetSessionVars().DistSQLScanConcurrency()) @@ -186,7 +186,7 @@ func (p *PhysicalTableReader) getPlanCostVer2(taskType property.TaskType, option } rows := getCardinality(p.tablePlan, option.CostFlag) - rowSize := getAvgRowSize(p.tablePlan.Stats(), p.tablePlan.Schema().Columns) + rowSize := getAvgRowSize(p.stats, p.schema.Columns) netFactor := getTaskNetFactorVer2(p, taskType) concurrency := float64(p.ctx.GetSessionVars().DistSQLScanConcurrency()) childType := property.CopSingleReadTaskType diff --git a/planner/core/testdata/plan_suite_out.json b/planner/core/testdata/plan_suite_out.json index e914b03ec72e2..18989bd56d94a 100644 --- a/planner/core/testdata/plan_suite_out.json +++ b/planner/core/testdata/plan_suite_out.json @@ -1104,7 +1104,7 @@ }, { "SQL": "select b from t where c = 1 or c = 2 or c = 3 or c = 4 or c = 5", - "Best": "IndexLookUp(Index(t.c_d_e)[[1,5]], Table(t))->Projection" + "Best": "TableReader(Table(t)->Sel([or(or(eq(test.t.c, 1), eq(test.t.c, 2)), or(eq(test.t.c, 3), or(eq(test.t.c, 4), eq(test.t.c, 5))))]))->Projection" }, { "SQL": "select a from t where c = 5", From b6b8e00a321a7ac4d77be9164fff2b7007201500 Mon Sep 17 00:00:00 2001 From: qw4990 Date: Wed, 9 Nov 2022 16:47:34 +0800 Subject: [PATCH 3/5] fixup --- planner/core/physical_plan_test.go | 1 + planner/core/rule_result_reorder_test.go | 1 + planner/core/stats_test.go | 1 + planner/core/testdata/stats_suite_out.json | 44 +++++++++++----------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/planner/core/physical_plan_test.go b/planner/core/physical_plan_test.go index d6ad45da76ee1..3ffdc92862dc7 100644 --- a/planner/core/physical_plan_test.go +++ b/planner/core/physical_plan_test.go @@ -1613,6 +1613,7 @@ func TestQueryBlockHint(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") var input []string var output []struct { diff --git a/planner/core/rule_result_reorder_test.go b/planner/core/rule_result_reorder_test.go index 0880f6426c151..09e0f1da35783 100644 --- a/planner/core/rule_result_reorder_test.go +++ b/planner/core/rule_result_reorder_test.go @@ -158,6 +158,7 @@ func TestOrderedResultModeOnOtherOperators(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("set tidb_enable_ordered_result_mode=1") tk.MustExec("drop table if exists t1") tk.MustExec("drop table if exists t2") diff --git a/planner/core/stats_test.go b/planner/core/stats_test.go index d9f4b5a015b38..2948c90abb4df 100644 --- a/planner/core/stats_test.go +++ b/planner/core/stats_test.go @@ -123,6 +123,7 @@ func TestNDVGroupCols(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists t1, t2") tk.MustExec("create table t1(a int not null, b int not null, key(a,b))") tk.MustExec("insert into t1 values(1,1),(1,2),(2,1),(2,2)") diff --git a/planner/core/testdata/stats_suite_out.json b/planner/core/testdata/stats_suite_out.json index 2fcc3c6518425..38eb118c4556c 100644 --- a/planner/core/testdata/stats_suite_out.json +++ b/planner/core/testdata/stats_suite_out.json @@ -218,23 +218,23 @@ { "SQL": "select count(1) from t1 left join t2 on t1.a = t2.a group by t1.a, t1.b", "Plan": [ - "HashAgg 4.00 root group by:test.t1.a, test.t1.b, funcs:count(1)->Column#7", - "└─HashJoin 12.00 root left outer join, equal:[eq(test.t1.a, test.t2.a)]", - " ├─TableReader(Build) 4.00 root data:TableFullScan", - " │ └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false", - " └─TableReader(Probe) 9.00 root data:TableFullScan", - " └─TableFullScan 9.00 cop[tikv] table:t2 keep order:false" + "StreamAgg 4.00 root group by:test.t1.a, test.t1.b, funcs:count(1)->Column#7", + "└─IndexJoin 12.00 root left outer join, inner:IndexReader, outer key:test.t1.a, inner key:test.t2.a, equal cond:eq(test.t1.a, test.t2.a)", + " ├─IndexReader(Build) 4.00 root index:IndexFullScan", + " │ └─IndexFullScan 4.00 cop[tikv] table:t1, index:a(a, b) keep order:true", + " └─IndexReader(Probe) 12.00 root index:IndexRangeScan", + " └─IndexRangeScan 12.00 cop[tikv] table:t2, index:a(a, b) range: decided by [eq(test.t2.a, test.t1.a)], keep order:false" ] }, { "SQL": "select count(1) from t1 right join t2 on t1.a = t2.a group by t2.a, t2.b", "Plan": [ - "HashAgg 9.00 root group by:test.t2.a, test.t2.b, funcs:count(1)->Column#7", - "└─HashJoin 12.00 root right outer join, equal:[eq(test.t1.a, test.t2.a)]", - " ├─TableReader(Build) 4.00 root data:TableFullScan", - " │ └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false", - " └─TableReader(Probe) 9.00 root data:TableFullScan", - " └─TableFullScan 9.00 cop[tikv] table:t2 keep order:false" + "StreamAgg 9.00 root group by:test.t2.a, test.t2.b, funcs:count(1)->Column#7", + "└─IndexJoin 12.00 root right outer join, inner:IndexReader, outer key:test.t2.a, inner key:test.t1.a, equal cond:eq(test.t2.a, test.t1.a)", + " ├─IndexReader(Build) 9.00 root index:IndexFullScan", + " │ └─IndexFullScan 9.00 cop[tikv] table:t2, index:a(a, b) keep order:true", + " └─IndexReader(Probe) 12.00 root index:IndexRangeScan", + " └─IndexRangeScan 12.00 cop[tikv] table:t1, index:a(a, b) range: decided by [eq(test.t1.a, test.t2.a)], keep order:false" ] }, { @@ -242,10 +242,10 @@ "Plan": [ "HashAgg 4.00 root group by:test.t1.a, test.t1.b, funcs:count(Column#10)->Column#11", "└─HashJoin 4.00 root left outer semi join, equal:[eq(test.t1.b, test.t2.b)], other cond:gt(test.t2.a, test.t1.a)", - " ├─TableReader(Build) 9.00 root data:TableFullScan", - " │ └─TableFullScan 9.00 cop[tikv] table:t2 keep order:false", - " └─TableReader(Probe) 4.00 root data:TableFullScan", - " └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false" + " ├─IndexReader(Build) 9.00 root index:IndexFullScan", + " │ └─IndexFullScan 9.00 cop[tikv] table:t2, index:a(a, b) keep order:false", + " └─IndexReader(Probe) 4.00 root index:IndexFullScan", + " └─IndexFullScan 4.00 cop[tikv] table:t1, index:a(a, b) keep order:false" ] }, { @@ -253,10 +253,10 @@ "Plan": [ "HashAgg 4.00 root group by:test.t1.a, test.t1.b, funcs:count(Column#10)->Column#11", "└─HashJoin 4.00 root anti left outer semi join, equal:[eq(test.t1.b, test.t2.b)], other cond:gt(test.t2.a, test.t1.a)", - " ├─TableReader(Build) 9.00 root data:TableFullScan", - " │ └─TableFullScan 9.00 cop[tikv] table:t2 keep order:false", - " └─TableReader(Probe) 4.00 root data:TableFullScan", - " └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false" + " ├─IndexReader(Build) 9.00 root index:IndexFullScan", + " │ └─IndexFullScan 9.00 cop[tikv] table:t2, index:a(a, b) keep order:false", + " └─IndexReader(Probe) 4.00 root index:IndexFullScan", + " └─IndexFullScan 4.00 cop[tikv] table:t1, index:a(a, b) keep order:false" ] }, { @@ -276,8 +276,8 @@ "Plan": [ "HashAgg 4.00 root group by:test.t1.a, test.t1.b, funcs:count(Column#5)->Column#6", "└─Window 4.00 root sum(cast(test.t1.a, decimal(10,0) BINARY))->Column#5 over()", - " └─TableReader 4.00 root data:TableFullScan", - " └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false" + " └─IndexReader 4.00 root index:IndexFullScan", + " └─IndexFullScan 4.00 cop[tikv] table:t1, index:a(a, b) keep order:false" ] } ] From b4eab946aecb2f3f07ebc6202c5d757bcfad77af Mon Sep 17 00:00:00 2001 From: qw4990 Date: Wed, 9 Nov 2022 17:02:46 +0800 Subject: [PATCH 4/5] fixup --- planner/core/physical_plan_test.go | 4 ++++ planner/core/testdata/plan_suite_out.json | 28 +++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/planner/core/physical_plan_test.go b/planner/core/physical_plan_test.go index 3ffdc92862dc7..36676cb9b1fdc 100644 --- a/planner/core/physical_plan_test.go +++ b/planner/core/physical_plan_test.go @@ -2173,6 +2173,7 @@ func TestHJBuildAndProbeHint(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists t1, t2, t3") tk.MustExec("create table t1(a int primary key, b int not null)") tk.MustExec("create table t2(a int primary key, b int not null)") @@ -2209,6 +2210,7 @@ func TestHJBuildAndProbeHint4StaticPartitionTable(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists t1, t2, t3") tk.MustExec(`create table t1(a int, b int) partition by hash(a) partitions 4`) tk.MustExec(`create table t2(a int, b int) partition by hash(a) partitions 5`) @@ -2283,6 +2285,7 @@ func TestHJBuildAndProbeHint4TiFlash(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists t1, t2, t3") tk.MustExec("create table t1(a int primary key, b int not null)") tk.MustExec("create table t2(a int primary key, b int not null)") @@ -2321,6 +2324,7 @@ func TestHJBuildAndProbeHintWithBinding(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("use test") + tk.MustExec("set tidb_cost_model_version=2") tk.MustExec("drop table if exists t, t1, t2, t3;") tk.MustExec("create table t(a int, b int, key(a));") tk.MustExec("create table t1(a int, b int, key(a));") diff --git a/planner/core/testdata/plan_suite_out.json b/planner/core/testdata/plan_suite_out.json index 18989bd56d94a..d1f44be61602b 100644 --- a/planner/core/testdata/plan_suite_out.json +++ b/planner/core/testdata/plan_suite_out.json @@ -5171,9 +5171,10 @@ "SQL": "SELECT /*+ hash_join_probe(t1) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a);", "Plan": [ "HashJoin 10000.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", - "├─HashAgg(Build) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a", - "│ └─TableReader 10000.00 root data:TableFullScan", - "│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "├─StreamAgg(Build) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a", + "│ └─TableReader 8000.00 root data:StreamAgg", + "│ └─StreamAgg 8000.00 cop[tikv] group by:test.t2.a, ", + "│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo", "└─TableReader(Probe) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ], @@ -5189,9 +5190,10 @@ "HashJoin 10000.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", "├─TableReader(Build) 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", - "└─HashAgg(Probe) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a", - " └─TableReader 10000.00 root data:TableFullScan", - " └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" + "└─StreamAgg(Probe) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a", + " └─TableReader 8000.00 root data:StreamAgg", + " └─StreamAgg 8000.00 cop[tikv] group by:test.t2.a, ", + " └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo" ], "Result": [ "1 1", @@ -5239,9 +5241,10 @@ "HashJoin 10000.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", "├─TableReader(Build) 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", - "└─HashAgg(Probe) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a", - " └─TableReader 10000.00 root data:TableFullScan", - " └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" + "└─StreamAgg(Probe) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a", + " └─TableReader 8000.00 root data:StreamAgg", + " └─StreamAgg 8000.00 cop[tikv] group by:test.t2.a, ", + " └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo" ], "Result": [ "1 1", @@ -5253,9 +5256,10 @@ "SQL": "SELECT /*+ hash_join_build(t2@sel_2) */ * FROM t1 WHERE EXISTS (SELECT /*+ SEMI_JOIN_REWRITE() */ 1 FROM t2 WHERE t2.a = t1.a);", "Plan": [ "HashJoin 10000.00 root inner join, equal:[eq(test.t1.a, test.t2.a)]", - "├─HashAgg(Build) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a", - "│ └─TableReader 10000.00 root data:TableFullScan", - "│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "├─StreamAgg(Build) 8000.00 root group by:test.t2.a, funcs:firstrow(test.t2.a)->test.t2.a", + "│ └─TableReader 8000.00 root data:StreamAgg", + "│ └─StreamAgg 8000.00 cop[tikv] group by:test.t2.a, ", + "│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:true, stats:pseudo", "└─TableReader(Probe) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ], From 1fc64911b61b0a795a10752ee49aee2b548a9bfd Mon Sep 17 00:00:00 2001 From: qw4990 Date: Wed, 9 Nov 2022 18:23:05 +0800 Subject: [PATCH 5/5] fixup --- planner/core/testdata/analyze_suite_out.json | 8 ++++---- planner/core/testdata/integration_suite_out.json | 10 +++++----- planner/core/testdata/plan_suite_out.json | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/planner/core/testdata/analyze_suite_out.json b/planner/core/testdata/analyze_suite_out.json index e19c4bb0596b3..38fc33be76916 100644 --- a/planner/core/testdata/analyze_suite_out.json +++ b/planner/core/testdata/analyze_suite_out.json @@ -380,8 +380,8 @@ [ "Projection 10.00 root Column#22", "└─Apply 10.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, Column#21)", - " ├─TableReader(Build) 10.00 root data:TableFullScan", - " │ └─TableFullScan 10.00 cop[tikv] table:t keep order:false", + " ├─IndexReader(Build) 10.00 root index:IndexFullScan", + " │ └─IndexFullScan 10.00 cop[tikv] table:t, index:idx(c, b, a) keep order:false", " └─StreamAgg(Probe) 10.00 root funcs:count(1)->Column#21", " └─HashJoin 10.00 root inner join, equal:[eq(test.t.a, test.t.a)]", " ├─IndexReader(Build) 10.00 root index:Selection", @@ -394,8 +394,8 @@ [ "Projection 10.00 root Column#13", "└─Apply 10.00 root CARTESIAN left outer join", - " ├─TableReader(Build) 10.00 root data:TableFullScan", - " │ └─TableFullScan 10.00 cop[tikv] table:t keep order:false", + " ├─IndexReader(Build) 10.00 root index:IndexFullScan", + " │ └─IndexFullScan 10.00 cop[tikv] table:t, index:idx(c, b, a) keep order:false", " └─MaxOneRow(Probe) 10.00 root ", " └─Projection 1.00 root concat(cast(test.t.a, var_string(20)), ,, cast(test.t.b, var_string(20)))->Column#13", " └─IndexReader 1.00 root index:Selection", diff --git a/planner/core/testdata/integration_suite_out.json b/planner/core/testdata/integration_suite_out.json index c042cde23ab44..304d84c59486a 100644 --- a/planner/core/testdata/integration_suite_out.json +++ b/planner/core/testdata/integration_suite_out.json @@ -2620,15 +2620,15 @@ { "SQL": "explain format = 'verbose' select (2) in (select /*+ read_from_storage(tiflash[t1]) */ count(*) from t1) from (select t.b < (select /*+ read_from_storage(tiflash[t2]) */ t.b from t2 limit 1 ) from t3 t) t", "Plan": [ - "HashJoin_19 3.00 160879.40 root CARTESIAN left outer semi join", + "HashJoin_19 3.00 160874.64 root CARTESIAN left outer semi join", "├─Selection_38(Build) 0.80 31154.89 root eq(2, Column#18)", "│ └─StreamAgg_45 1.00 31104.99 root funcs:count(1)->Column#18", "│ └─TableReader_59 3.00 30955.29 root data:TableFullScan_58", "│ └─TableFullScan_58 3.00 464139.20 cop[tiflash] table:t1 keep order:false", - "└─Projection_20(Probe) 3.00 129653.38 root 1->Column#28", - " └─Apply_22 3.00 129653.08 root CARTESIAN left outer join", - " ├─TableReader_24(Build) 3.00 58.13 root data:TableFullScan_23", - " │ └─TableFullScan_23 3.00 681.92 cop[tikv] table:t keep order:false", + "└─Projection_20(Probe) 3.00 129648.62 root 1->Column#28", + " └─Apply_22 3.00 129648.32 root CARTESIAN left outer join", + " ├─IndexReader_26(Build) 3.00 53.37 root index:IndexFullScan_25", + " │ └─IndexFullScan_25 3.00 610.50 cop[tikv] table:t, index:c(b) keep order:false", " └─Projection_27(Probe) 3.00 43198.32 root 1->Column#26", " └─Limit_30 3.00 43198.22 root offset:0, count:1", " └─TableReader_37 3.00 43198.22 root data:ExchangeSender_36", diff --git a/planner/core/testdata/plan_suite_out.json b/planner/core/testdata/plan_suite_out.json index d1f44be61602b..43a23f6cf075f 100644 --- a/planner/core/testdata/plan_suite_out.json +++ b/planner/core/testdata/plan_suite_out.json @@ -959,7 +959,7 @@ }, { "SQL": "select sum(e), avg(e + c) from t where c = 1 group by c", - "Best": "IndexReader(Index(t.c_d_e)[[1,1]]->StreamAgg)->StreamAgg" + "Best": "IndexReader(Index(t.c_d_e)[[1,1]])->Projection->StreamAgg" }, { "SQL": "select sum(e), avg(e + c) from t where c = 1 group by e",