[ { "Name": "TestPushLimitDownIndexLookUpReader", "Cases": [ { "SQL": "explain format = 'brief' select * from tbl use index(idx_b_c) where b > 1 limit 2,1", "Plan": [ "IndexLookUp 1.00 root limit embedded(offset:2, count:1)", "├─Limit(Build) 3.00 cop[tikv] offset:0, count:3", "│ └─IndexRangeScan 3.00 cop[tikv] table:tbl, index:idx_b_c(b, c) range:(1,+inf], keep order:false", "└─TableRowIDScan(Probe) 1.00 cop[tikv] table:tbl keep order:false" ] }, { "SQL": "explain format = 'brief' select * from tbl use index(idx_b_c) where b > 1 order by b desc limit 2,1", "Plan": [ "Limit 1.00 root offset:2, count:1", "└─Projection 3.00 root test.tbl.a, test.tbl.b, test.tbl.c", " └─IndexLookUp 3.00 root ", " ├─Limit(Build) 3.00 cop[tikv] offset:0, count:3", " │ └─IndexRangeScan 3.00 cop[tikv] table:tbl, index:idx_b_c(b, c) range:(1,+inf], keep order:true, desc", " └─TableRowIDScan(Probe) 3.00 cop[tikv] table:tbl keep order:false" ] }, { "SQL": "explain format = 'brief' select * from tbl use index(idx_b_c) where b > 1 and c > 1 limit 2,1", "Plan": [ "IndexLookUp 1.00 root limit embedded(offset:2, count:1)", "├─Limit(Build) 3.00 cop[tikv] offset:0, count:3", "│ └─Selection 3.00 cop[tikv] gt(test.tbl.c, 1)", "│ └─IndexRangeScan 3.75 cop[tikv] table:tbl, index:idx_b_c(b, c) range:(1,+inf], keep order:false", "└─TableRowIDScan(Probe) 1.00 cop[tikv] table:tbl keep order:false" ] }, { "SQL": "explain format = 'brief' select * from tbl use index(idx_b_c) where b > 1 and a > 1 limit 2,1", "Plan": [ "Limit 1.00 root offset:2, count:1", "└─IndexLookUp 3.00 root ", " ├─IndexRangeScan(Build) 3.75 cop[tikv] table:tbl, index:idx_b_c(b, c) range:(1,+inf], keep order:false", " └─Limit(Probe) 3.00 cop[tikv] offset:0, count:3", " └─Selection 3.00 cop[tikv] gt(test.tbl.a, 1)", " └─TableRowIDScan 3.75 cop[tikv] table:tbl keep order:false" ] } ] }, { "Name": "TestIsFromUnixtimeNullRejective", "Cases": [ { "SQL": "explain format = 'brief' select * from t t1 left join t t2 on t1.a=t2.a where from_unixtime(t2.b);", "Plan": [ "Projection 9990.00 root test.t.a, test.t.b, test.t.a, test.t.b", "└─HashJoin 9990.00 root inner join, equal:[eq(test.t.a, test.t.a)]", " ├─Selection(Build) 7992.00 root from_unixtime(cast(test.t.b, decimal(20,0) BINARY))", " │ └─TableReader 9990.00 root data:Selection", " │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.a))", " │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", " └─TableReader(Probe) 9990.00 root data:Selection", " └─Selection 9990.00 cop[tikv] not(isnull(test.t.a))", " └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] } ] }, { "Name": "TestAggColumnPrune", "Cases": [ { "SQL": "select count(1) from t join (select count(1) from t where false) as tmp", "Res": [ "2" ] }, { "SQL": "select count(1) from t join (select max(a) from t where false) as tmp", "Res": [ "2" ] }, { "SQL": "select count(1) from t join (select min(a) from t where false) as tmp", "Res": [ "2" ] }, { "SQL": "select count(1) from t join (select sum(a) from t where false) as tmp", "Res": [ "2" ] }, { "SQL": "select count(1) from t join (select avg(a) from t where false) as tmp", "Res": [ "2" ] }, { "SQL": "select count(1) from t join (select count(1) from t where false group by a) as tmp", "Res": [ "0" ] }, { "SQL": "select count(1) from t join (select max(a) from t where false group by a) as tmp", "Res": [ "0" ] }, { "SQL": "select count(1) from t join (select min(a) from t where false group by a) as tmp", "Res": [ "0" ] }, { "SQL": "select count(1) from t join (select sum(a) from t where false group by a) as tmp", "Res": [ "0" ] }, { "SQL": "select count(1) from t join (select avg(a) from t where false group by a) as tmp", "Res": [ "0" ] }, { "SQL": "SELECT avg(2) FROM(SELECT min(c) FROM t JOIN(SELECT 1 c) d ORDER BY a) e", "Res": [ "2.0000" ] } ] }, { "Name": "TestIndexJoinInnerIndexNDV", "Cases": [ { "SQL": "explain format = 'brief' select /*+ inl_join(t2) */ * from t1, t2 where t1.a = t2.a and t1.b = t2.b and t1.c = t2.c", "Plan": [ "IndexJoin 3.00 root inner join, inner:IndexLookUp, outer key:test.t1.c, inner key:test.t2.c, equal cond:eq(test.t1.a, test.t2.a), eq(test.t1.b, test.t2.b), eq(test.t1.c, test.t2.c)", "├─TableReader(Build) 3.00 root data:TableFullScan", "│ └─TableFullScan 3.00 cop[tikv] table:t1 keep order:false", "└─IndexLookUp(Probe) 1.00 root ", " ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t2, index:idx2(c) range: decided by [eq(test.t2.c, test.t1.c)], keep order:false", " └─TableRowIDScan(Probe) 1.00 cop[tikv] table:t2 keep order:false" ] } ] }, { "Name": "TestSimplifyOuterJoinWithCast", "Cases": [ { "SQL": "explain format = 'brief' select * from t t1 left join t t2 on t1.a = t2.a where cast(t1.b as date) >= '2019-01-01'", "Plan": [ "HashJoin 10000.00 root left outer join, equal:[eq(test.t.a, test.t.a)]", "├─TableReader(Build) 8000.00 root data:Selection", "│ └─Selection 8000.00 cop[tikv] ge(cast(test.t.b, date BINARY), 2019-01-01 00:00:00.000000)", "│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─TableReader(Probe) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] } ] }, { "Name": "TestMaxMinEliminate", "Cases": [ { "SQL": "explain format = 'brief' (select max(a) from t) union (select min(a) from t)", "Plan": [ "HashAgg 2.00 root group by:Column#5, funcs:firstrow(Column#5)->Column#5", "└─Union 2.00 root ", " ├─StreamAgg 1.00 root funcs:max(test.t.a)->Column#2", " │ └─Limit 1.00 root offset:0, count:1", " │ └─TableReader 1.00 root data:Limit", " │ └─Limit 1.00 cop[tikv] offset:0, count:1", " │ └─TableFullScan 1.00 cop[tikv] table:t keep order:true, desc, stats:pseudo", " └─StreamAgg 1.00 root funcs:min(test.t.a)->Column#4", " └─Limit 1.00 root offset:0, count:1", " └─TableReader 1.00 root data:Limit", " └─Limit 1.00 cop[tikv] offset:0, count:1", " └─TableFullScan 1.00 cop[tikv] table:t keep order:true, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select min(a), max(a) from cluster_index_t", "Plan": [ "HashJoin 1.00 root CARTESIAN inner join", "├─StreamAgg(Build) 1.00 root funcs:max(test.cluster_index_t.a)->Column#5", "│ └─Limit 1.00 root offset:0, count:1", "│ └─TableReader 1.00 root data:Limit", "│ └─Limit 1.00 cop[tikv] offset:0, count:1", "│ └─TableFullScan 1.00 cop[tikv] table:cluster_index_t keep order:true, desc, stats:pseudo", "└─StreamAgg(Probe) 1.00 root funcs:min(test.cluster_index_t.a)->Column#4", " └─Limit 1.00 root offset:0, count:1", " └─TableReader 1.00 root data:Limit", " └─Limit 1.00 cop[tikv] offset:0, count:1", " └─TableFullScan 1.00 cop[tikv] table:cluster_index_t keep order:true, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select min(b), max(b) from cluster_index_t where a = 1", "Plan": [ "HashJoin 1.00 root CARTESIAN inner join", "├─StreamAgg(Build) 1.00 root funcs:max(test.cluster_index_t.b)->Column#5", "│ └─Limit 1.00 root offset:0, count:1", "│ └─TableReader 1.00 root data:Limit", "│ └─Limit 1.00 cop[tikv] offset:0, count:1", "│ └─TableRangeScan 1.00 cop[tikv] table:cluster_index_t range:[1,1], keep order:true, desc, stats:pseudo", "└─StreamAgg(Probe) 1.00 root funcs:min(test.cluster_index_t.b)->Column#4", " └─Limit 1.00 root offset:0, count:1", " └─TableReader 1.00 root data:Limit", " └─Limit 1.00 cop[tikv] offset:0, count:1", " └─TableRangeScan 1.00 cop[tikv] table:cluster_index_t range:[1,1], keep order:true, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select min(a), max(a) from cluster_index_t where b = 1", "Plan": [ "StreamAgg 1.00 root funcs:min(Column#8)->Column#4, funcs:max(Column#9)->Column#5", "└─TableReader 1.00 root data:StreamAgg", " └─StreamAgg 1.00 cop[tikv] funcs:min(test.cluster_index_t.a)->Column#8, funcs:max(test.cluster_index_t.a)->Column#9", " └─Selection 10.00 cop[tikv] eq(test.cluster_index_t.b, 1)", " └─TableFullScan 10000.00 cop[tikv] table:cluster_index_t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select min(b), max(b) from cluster_index_t where b = 1", "Plan": [ "StreamAgg 1.00 root funcs:min(Column#8)->Column#4, funcs:max(Column#9)->Column#5", "└─TableReader 1.00 root data:StreamAgg", " └─StreamAgg 1.00 cop[tikv] funcs:min(test.cluster_index_t.b)->Column#8, funcs:max(test.cluster_index_t.b)->Column#9", " └─Selection 10.00 cop[tikv] eq(test.cluster_index_t.b, 1)", " └─TableFullScan 10000.00 cop[tikv] table:cluster_index_t keep order:false, stats:pseudo" ] } ] }, { "Name": "TestIndexJoinUniqueCompositeIndex", "Cases": [ { "SQL": "explain format = 'brief' select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a and t1.c = t2.c", "Plan": [ "IndexJoin 2.00 root inner join, inner:IndexLookUp, outer key:test.t1.a, inner key:test.t2.a, equal cond:eq(test.t1.a, test.t2.a), eq(test.t1.c, test.t2.c)", "├─TableReader(Build) 1.00 root data:TableFullScan", "│ └─TableFullScan 1.00 cop[tikv] table:t1 keep order:false", "└─IndexLookUp(Probe) 2.00 root ", " ├─IndexRangeScan(Build) 2.00 cop[tikv] table:t2, index:PRIMARY(a, b) range: decided by [eq(test.t2.a, test.t1.a)], keep order:false", " └─TableRowIDScan(Probe) 2.00 cop[tikv] table:t2 keep order:false" ] }, { "SQL": "explain format = 'brief' select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a and t1.c <= t2.b", "Plan": [ "IndexJoin 2.00 root inner join, inner:IndexLookUp, outer key:test.t1.a, inner key:test.t2.a, equal cond:eq(test.t1.a, test.t2.a), other cond:le(test.t1.c, test.t2.b)", "├─TableReader(Build) 1.00 root data:TableFullScan", "│ └─TableFullScan 1.00 cop[tikv] table:t1 keep order:false", "└─IndexLookUp(Probe) 2.00 root ", " ├─IndexRangeScan(Build) 2.00 cop[tikv] table:t2, index:PRIMARY(a, b) range: decided by [eq(test.t2.a, test.t1.a) le(test.t1.c, test.t2.b)], keep order:false", " └─TableRowIDScan(Probe) 2.00 cop[tikv] table:t2 keep order:false" ] }, { "SQL": "explain format = 'brief' select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a and t2.b = 1", "Plan": [ "IndexJoin 1.00 root inner join, inner:IndexLookUp, outer key:test.t1.a, inner key:test.t2.a, equal cond:eq(test.t1.a, test.t2.a)", "├─TableReader(Build) 1.00 root data:TableFullScan", "│ └─TableFullScan 1.00 cop[tikv] table:t1 keep order:false", "└─IndexLookUp(Probe) 1.00 root ", " ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t2, index:PRIMARY(a, b) range: decided by [eq(test.t2.a, test.t1.a) eq(test.t2.b, 1)], keep order:false", " └─TableRowIDScan(Probe) 1.00 cop[tikv] table:t2 keep order:false" ] } ] }, { "Name": "TestPartitionTableStats", "Cases": [ { "SQL": "explain format = 'brief' select * from t order by a", "Result": [ "Sort 10005.00 root test.t.a", "└─PartitionUnion 10005.00 root ", " ├─TableReader 10000.00 root data:TableFullScan", " │ └─TableFullScan 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo", " ├─TableReader 1.00 root data:TableFullScan", " │ └─TableFullScan 1.00 cop[tikv] table:t, partition:p1 keep order:false", " └─TableReader 4.00 root data:TableFullScan", " └─TableFullScan 4.00 cop[tikv] table:t, partition:p2 keep order:false" ] }, { "SQL": "select * from t order by a", "Result": [ "15 5", "21 1", "22 2", "23 3", "24 4" ] }, { "SQL": "explain format = 'brief' select * from t order by a limit 3", "Result": [ "TopN 3.00 root test.t.a, offset:0, count:3", "└─PartitionUnion 7.00 root ", " ├─TopN 3.00 root test.t.a, offset:0, count:3", " │ └─TableReader 3.00 root data:TopN", " │ └─TopN 3.00 cop[tikv] test.t.a, offset:0, count:3", " │ └─TableFullScan 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo", " ├─TopN 1.00 root test.t.a, offset:0, count:3", " │ └─TableReader 1.00 root data:TableFullScan", " │ └─TableFullScan 1.00 cop[tikv] table:t, partition:p1 keep order:false", " └─TopN 3.00 root test.t.a, offset:0, count:3", " └─TableReader 3.00 root data:TopN", " └─TopN 3.00 cop[tikv] test.t.a, offset:0, count:3", " └─TableFullScan 4.00 cop[tikv] table:t, partition:p2 keep order:false" ] }, { "SQL": "select * from t order by a limit 3", "Result": [ "15 5", "21 1", "22 2" ] } ] }, { "Name": "TestIndexMerge", "Cases": [ { "SQL": "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, a, b) */ * from t where a = 1 or b = 2", "Plan": [ "IndexMerge 2.00 root ", "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false, stats:pseudo", "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:b(b) range:[2,2], keep order:false, stats:pseudo", "└─TableRowIDScan(Probe) 2.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, primary) */ * from t where 1 or t.c", "Plan": [ "TableReader 10000.00 root data:TableFullScan", "└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, a, b, c) */ * from t where 1 or t.a = 1 or t.b = 2", "Plan": [ "TableReader 8000.40 root data:Selection", "└─Selection 8000.40 cop[tikv] or(1, or(eq(test.t.a, 1), eq(test.t.b, 2)))", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] } ] }, { "Name": "TestIndexMergeHint4CNF", "Cases": [ { "SQL": "explain format = 'brief' select * from t where b = 1 and (a = 1 or c = 1)", "Plan": [ "IndexLookUp 0.02 root ", "├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:b(b) range:[1,1], keep order:false, stats:pseudo", "└─Selection(Probe) 0.02 cop[tikv] or(eq(test.t.a, 1), eq(test.t.c, 1))", " └─TableRowIDScan 10.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select /*+ USE_INDEX_MERGE(t, a, c) */ * from t where b = 1 and (a = 1 or c = 1)", "Plan": [ "IndexMerge 0.02 root ", "├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false, stats:pseudo", "├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:c(c) range:[1,1], keep order:false, stats:pseudo", "└─Selection(Probe) 0.02 cop[tikv] eq(test.t.b, 1)", " └─TableRowIDScan 19.99 cop[tikv] table:t keep order:false, stats:pseudo" ] } ] }, { "Name": "TestSubqueryWithTopN", "Cases": [ { "SQL": "desc format = 'brief' select t1.b from t t1 where t1.b in (select t2.a from t t2 order by t1.a+t2.a limit 1)", "Plan": [ "Projection 9990.00 root test.t.b", "└─Apply 9990.00 root semi join, equal:[eq(test.t.b, test.t.a)]", " ├─TableReader(Build) 9990.00 root data:Selection", " │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.b))", " │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", " └─Selection(Probe) 0.80 root not(isnull(test.t.a))", " └─Projection 1.00 root test.t.a", " └─TopN 1.00 root Column#7, offset:0, count:1", " └─Projection 1.00 root test.t.a, plus(test.t.a, test.t.a)->Column#7", " └─TableReader 1.00 root data:TopN", " └─TopN 1.00 cop[tikv] plus(test.t.a, test.t.a), offset:0, count:1", " └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "desc format = 'brief' select t1.a from t t1 order by (t1.b = 1 and exists (select 1 from t t2 where t1.b = t2.b)) limit 1", "Plan": [ "Projection 1.00 root test.t.a", "└─Projection 1.00 root test.t.a, test.t.b, Column#11", " └─TopN 1.00 root Column#13, offset:0, count:1", " └─Projection 10000.00 root test.t.a, test.t.b, Column#11, and(eq(test.t.b, 1), Column#11)->Column#13", " └─HashJoin 10000.00 root left outer semi join, equal:[eq(test.t.b, test.t.b)]", " ├─TableReader(Build) 10000.00 root data:TableFullScan", " │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", " └─TableReader(Probe) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "desc format = 'brief' select * from (select b+b as x from t) t1, t t2 where t1.x=t2.b order by t1.x limit 1", "Plan": [ "TopN 1.00 root Column#4, offset:0, count:1", "└─Projection 10000.00 root Column#4, test.t.a, test.t.b", " └─HashJoin 10000.00 root inner join, equal:[eq(test.t.b, Column#4)]", " ├─Projection(Build) 8000.00 root plus(test.t.b, test.t.b)->Column#4", " │ └─TableReader 8000.00 root data:Selection", " │ └─Selection 8000.00 cop[tikv] not(isnull(plus(test.t.b, test.t.b)))", " │ └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo", " └─TableReader(Probe) 9990.00 root data:Selection", " └─Selection 9990.00 cop[tikv] not(isnull(test.t.b))", " └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] } ] }, { "Name": "TestIndexJoinTableRange", "Cases": [ { "SQL": "desc format = 'brief' select /*+ TIDB_INLJ(t2)*/ * from t1, t2 where t1.a = t2.a and t1.b = t2.b", "Plan": [ "IndexJoin 12487.50 root inner join, inner:TableReader, outer key:test.t1.a, inner key:test.t2.a, equal cond:eq(test.t1.a, test.t2.a), eq(test.t1.b, test.t2.b)", "├─IndexReader(Build) 9990.00 root index:IndexFullScan", "│ └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_t1_b(b) keep order:false, stats:pseudo", "└─TableReader(Probe) 1.00 root data:Selection", " └─Selection 1.00 cop[tikv] not(isnull(test.t2.b))", " └─TableRangeScan 1.00 cop[tikv] table:t2 range: decided by [test.t1.a], keep order:false, stats:pseudo" ] }, { "SQL": "desc format = 'brief' select /*+ TIDB_INLJ(t2)*/ * from t1, t2 where t1.a = t2.a and t1.b = t2.a and t1.b = t2.b", "Plan": [ "IndexJoin 12487.50 root inner join, inner:TableReader, outer key:test.t1.a, test.t1.b, inner key:test.t2.a, test.t2.a, equal cond:eq(test.t1.a, test.t2.a), eq(test.t1.b, test.t2.a), eq(test.t1.b, test.t2.b)", "├─IndexReader(Build) 9990.00 root index:IndexFullScan", "│ └─IndexFullScan 9990.00 cop[tikv] table:t1, index:idx_t1_b(b) keep order:false, stats:pseudo", "└─TableReader(Probe) 1.00 root data:Selection", " └─Selection 1.00 cop[tikv] not(isnull(test.t2.b))", " └─TableRangeScan 1.00 cop[tikv] table:t2 range: decided by [test.t1.a test.t1.b], keep order:false, stats:pseudo" ] } ] }, { "Name": "TestHintWithRequiredProperty", "Cases": [ { "SQL": "desc format = 'brief' select /*+ INL_JOIN(t2) */ * from t t1, t t2 where t1.a = t2.b order by t2.a", "Plan": [ "Sort 12487.50 root test.t.a", "└─IndexJoin 12487.50 root inner join, inner:IndexLookUp, outer key:test.t.a, inner key:test.t.b, equal cond:eq(test.t.a, test.t.b)", " ├─TableReader(Build) 10000.00 root data:TableFullScan", " │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", " └─IndexLookUp(Probe) 1.25 root ", " ├─Selection(Build) 1.25 cop[tikv] not(isnull(test.t.b))", " │ └─IndexRangeScan 1.25 cop[tikv] table:t2, index:b(b) range: decided by [eq(test.t.b, test.t.a)], keep order:false, stats:pseudo", " └─TableRowIDScan(Probe) 1.25 cop[tikv] table:t2 keep order:false, stats:pseudo" ], "Warnings": [] }, { "SQL": "desc format = 'brief' select /*+ INL_HASH_JOIN(t2) */ * from t t1, t t2 where t1.a = t2.b order by t2.a", "Plan": [ "Sort 12487.50 root test.t.a", "└─IndexHashJoin 12487.50 root inner join, inner:IndexLookUp, outer key:test.t.a, inner key:test.t.b, equal cond:eq(test.t.a, test.t.b)", " ├─TableReader(Build) 10000.00 root data:TableFullScan", " │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", " └─IndexLookUp(Probe) 1.25 root ", " ├─Selection(Build) 1.25 cop[tikv] not(isnull(test.t.b))", " │ └─IndexRangeScan 1.25 cop[tikv] table:t2, index:b(b) range: decided by [eq(test.t.b, test.t.a)], keep order:false, stats:pseudo", " └─TableRowIDScan(Probe) 1.25 cop[tikv] table:t2 keep order:false, stats:pseudo" ], "Warnings": [] }, { "SQL": "desc format = 'brief' select /*+ INL_MERGE_JOIN(t2)*/ t1.a, t2.a from t t1, t t2 ,t t3 where t1.a = t2.a and t3.a=t2.a", "Plan": [ "HashJoin 15625.00 root inner join, equal:[eq(test.t.a, test.t.a)]", "├─TableReader(Build) 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo", "└─IndexMergeJoin(Probe) 12500.00 root inner join, inner:TableReader, outer key:test.t.a, inner key:test.t.a", " ├─TableReader(Build) 10000.00 root data:TableFullScan", " │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", " └─TableReader(Probe) 1.00 root data:TableRangeScan", " └─TableRangeScan 1.00 cop[tikv] table:t2 range: decided by [test.t.a], keep order:true, stats:pseudo" ], "Warnings": [] }, { "SQL": "desc format = 'brief' select * from t t1, (select /*+ HASH_AGG() */ b, max(a) from t t2 group by b) t2 where t1.b = t2.b order by t1.b", "Plan": [ "Sort 9990.00 root test.t.b", "└─Projection 9990.00 root test.t.a, test.t.b, test.t.c, test.t.b, Column#7", " └─HashJoin 9990.00 root inner join, equal:[eq(test.t.b, test.t.b)]", " ├─HashAgg(Build) 7992.00 root group by:test.t.b, funcs:max(Column#10)->Column#7, funcs:firstrow(test.t.b)->test.t.b", " │ └─IndexReader 7992.00 root index:HashAgg", " │ └─HashAgg 7992.00 cop[tikv] group by:test.t.b, funcs:max(test.t.a)->Column#10", " │ └─IndexFullScan 9990.00 cop[tikv] table:t2, index:b(b) keep order:false, stats:pseudo", " └─TableReader(Probe) 9990.00 root data:Selection", " └─Selection 9990.00 cop[tikv] not(isnull(test.t.b))", " └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ], "Warnings": [] }, { "SQL": "desc format = 'brief' select /*+ INL_HASH_JOIN(t2) */ distinct t2.a from t t1 join t t2 on t1.a = t2.a", "Plan": [ "IndexHashJoin 12500.00 root inner join, inner:TableReader, outer key:test.t.a, inner key:test.t.a, equal cond:eq(test.t.a, test.t.a)", "├─TableReader(Build) 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─TableReader(Probe) 1.00 root data:TableRangeScan", " └─TableRangeScan 1.00 cop[tikv] table:t2 range: decided by [test.t.a], keep order:false, stats:pseudo" ], "Warnings": [] }, { "SQL": "desc format = 'brief' select /*+ INL_JOIN(t2) */ * from t t1, t t2 where t1.a = t2.c order by t1.a", "Plan": [ "Sort 12487.50 root test.t.a", "└─HashJoin 12487.50 root inner join, equal:[eq(test.t.a, test.t.c)]", " ├─TableReader(Build) 9990.00 root data:Selection", " │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.c))", " │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", " └─TableReader(Probe) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ], "Warnings": [ "[planner:1815]Optimizer Hint /*+ INL_JOIN(t2) */ or /*+ TIDB_INLJ(t2) */ is inapplicable", "[planner:1815]Optimizer Hint /*+ INL_JOIN(t2) */ or /*+ TIDB_INLJ(t2) */ is inapplicable" ] } ] }, { "Name": "TestIndexHintWarning", "Cases": [ { "SQL": "select /*+ USE_INDEX(t1, j) */ * from t1", "Warnings": [ "[planner:1176]Key 'j' doesn't exist in table 't1'" ] }, { "SQL": "select /*+ IGNORE_INDEX(t1, j) */ * from t1", "Warnings": [ "[planner:1176]Key 'j' doesn't exist in table 't1'" ] }, { "SQL": "select /*+ USE_INDEX(t2, a, b, c) */ * from t1", "Warnings": [ "[planner:1815]use_index(test.t2, a, b, c) is inapplicable, check whether the table(test.t2) exists" ] }, { "SQL": "select /*+ USE_INDEX(t2) */ * from t1", "Warnings": [ "[planner:1815]use_index(test.t2) is inapplicable, check whether the table(test.t2) exists" ] }, { "SQL": "select /*+ USE_INDEX(t1, a), USE_INDEX(t2, a), USE_INDEX(t3, a) */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[planner:1815]use_index(test.t3, a) is inapplicable, check whether the table(test.t3) exists" ] }, { "SQL": "select /*+ USE_INDEX(t3, a), USE_INDEX(t4, b), IGNORE_INDEX(t3, a) */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[planner:1815]use_index(test.t3, a) is inapplicable, check whether the table(test.t3) exists", "[planner:1815]use_index(test.t4, b) is inapplicable, check whether the table(test.t4) exists", "[planner:1815]ignore_index(test.t3, a) is inapplicable, check whether the table(test.t3) exists" ] }, { "SQL": "select /*+ USE_INDEX_MERGE(t3, a, b, d) */ * from t1", "Warnings": [ "[planner:1815]use_index_merge(test.t3, a, b, d) is inapplicable, check whether the table(test.t3) exists" ] }, { "SQL": "select /*+ USE_INDEX_MERGE(t1, a, b, c, d) */ * from t1", "Warnings": [ "[planner:1815]use_index_merge(test.t1, a, b, c, d) is inapplicable, check whether the indexes (c, d) exist, or the indexes are conflicted with use_index/ignore_index/force_index hints." ] }, { "SQL": "select /*+ USE_INDEX_MERGE(t1, a, b), USE_INDEX(t1, a) */ * from t1", "Warnings": [ "[planner:1815]use_index_merge(test.t1, a, b) is inapplicable, check whether the indexes (b) exist, or the indexes are conflicted with use_index/ignore_index/force_index hints." ] }, { "SQL": "select /*+ USE_INDEX_MERGE(t1, a, b), IGNORE_INDEX(t1, a) */ * from t1", "Warnings": [ "[planner:1815]use_index_merge(test.t1, a, b) is inapplicable, check whether the indexes (a) exist, or the indexes are conflicted with use_index/ignore_index/force_index hints." ] }, { "SQL": "select /*+ USE_INDEX_MERGE(t1, primary, a, b, c) */ * from t1", "Warnings": [ "[planner:1815]use_index_merge(test.t1, primary, a, b, c) is inapplicable, check whether the indexes (c) exist, or the indexes are conflicted with use_index/ignore_index/force_index hints." ] } ] }, { "Name": "TestHintWithoutTableWarning", "Cases": [ { "SQL": "select /*+ TIDB_SMJ() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[planner:1815]Hint TIDB_SMJ() is inapplicable. Please specify the table names in the arguments." ] }, { "SQL": "select /*+ MERGE_JOIN() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[planner:1815]Hint MERGE_JOIN() is inapplicable. Please specify the table names in the arguments." ] }, { "SQL": "select /*+ INL_JOIN() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[planner:1815]Hint INL_JOIN() is inapplicable. Please specify the table names in the arguments." ] }, { "SQL": "select /*+ TIDB_INLJ() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[planner:1815]Hint TIDB_INLJ() is inapplicable. Please specify the table names in the arguments." ] }, { "SQL": "select /*+ INL_HASH_JOIN() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[planner:1815]Hint INL_HASH_JOIN() is inapplicable. Please specify the table names in the arguments." ] }, { "SQL": "select /*+ INL_MERGE_JOIN() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[planner:1815]Hint INL_MERGE_JOIN() is inapplicable. Please specify the table names in the arguments." ] }, { "SQL": "select /*+ HASH_JOIN() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[planner:1815]Hint HASH_JOIN() is inapplicable. Please specify the table names in the arguments." ] }, { "SQL": "select /*+ USE_INDEX() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[parser:1064]Optimizer hint syntax error at line 1 column 22 near \") */\" " ] }, { "SQL": "select /*+ IGNORE_INDEX() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[parser:1064]Optimizer hint syntax error at line 1 column 25 near \") */\" " ] }, { "SQL": "select /*+ USE_INDEX_MERGE() */ * from t1, t2 where t1.a=t2.a", "Warnings": [ "[parser:1064]Optimizer hint syntax error at line 1 column 28 near \") */\" " ] } ] }, { "Name": "TestPartitionPruningForInExpr", "Cases": [ { "SQL": "explain format = 'brief' select * from t where a in (1, 2,'11')", "Plan": [ "TableReader 30.00 root partition:p0,p2 data:Selection", "└─Selection 30.00 cop[tikv] in(test.t.a, 1, 2, 11)", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select * from t where a in (17, null)", "Plan": [ "TableReader 10.00 root partition:p0,p2 data:Selection", "└─Selection 10.00 cop[tikv] in(test.t.a, 17, NULL)", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select * from t where a in (16, 'abc')", "Plan": [ "TableReader 20.00 root partition:p0,p2 data:Selection", "└─Selection 20.00 cop[tikv] in(test.t.a, 16, 0)", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select * from t where a in (15, 0.12, 3.47)", "Plan": [ "TableReader 10.00 root partition:p2 data:Selection", "└─Selection 10.00 cop[tikv] or(eq(test.t.a, 15), 0)", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select * from t where a in (0.12, 3.47)", "Plan": [ "TableDual 0.00 root rows:0" ] }, { "SQL": "explain format = 'brief' select * from t where a in (14, floor(3.47))", "Plan": [ "TableReader 20.00 root partition:p0,p2 data:Selection", "└─Selection 20.00 cop[tikv] in(test.t.a, 14, 3)", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select * from t where b in (3, 4)", "Plan": [ "TableReader 20.00 root partition:all data:Selection", "└─Selection 20.00 cop[tikv] in(test.t.b, 3, 4)", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] } ] }, { "Name": "TestStreamAggProp", "Cases": [ { "SQL": "select /*+ stream_agg() */ count(*) c from t group by a order by c limit 1", "Plan": [ "TopN 1.00 root Column#3, offset:0, count:1", "└─StreamAgg 8000.00 root group by:test.t.a, funcs:count(1)->Column#3", " └─Sort 10000.00 root test.t.a", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Res": [ "1" ] }, { "SQL": "select /*+ stream_agg() */ count(*) c from t group by a order by c", "Plan": [ "Sort 8000.00 root Column#3", "└─StreamAgg 8000.00 root group by:test.t.a, funcs:count(1)->Column#3", " └─Sort 10000.00 root test.t.a", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Res": [ "1", "2" ] }, { "SQL": "select /*+ stream_agg() */ count(*) c from t group by a order by a limit 1", "Plan": [ "Projection 1.00 root Column#3", "└─Limit 1.00 root offset:0, count:1", " └─StreamAgg 1.00 root group by:test.t.a, funcs:count(1)->Column#3, funcs:firstrow(test.t.a)->test.t.a", " └─Sort 1.25 root test.t.a", " └─TableReader 1.25 root data:TableFullScan", " └─TableFullScan 1.25 cop[tikv] table:t keep order:false, stats:pseudo" ], "Res": [ "2" ] }, { "SQL": "select /*+ stream_agg() */ count(*) c from t group by a order by a", "Plan": [ "Projection 8000.00 root Column#3", "└─StreamAgg 8000.00 root group by:test.t.a, funcs:count(1)->Column#3, funcs:firstrow(test.t.a)->test.t.a", " └─Sort 10000.00 root test.t.a", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Res": [ "2", "1" ] } ] }, { "Name": "TestOptimizeHintOnPartitionTable", "Cases": [ { "SQL": "select /*+ use_index(t) */ * from t", "Plan": [ "PartitionUnion 30000.00 root ", "├─TableReader 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo", "├─TableReader 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo", "└─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t, partition:p2 keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "select /*+ use_index(t partition(p0, p1) b, c) */ * from t partition(p1,p2)", "Plan": [ "PartitionUnion 20000.00 root ", "├─IndexLookUp 10000.00 root ", "│ ├─IndexFullScan(Build) 10000.00 cop[tikv] table:t, partition:p1, index:b(b) keep order:false, stats:pseudo", "│ └─TableRowIDScan(Probe) 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo", "└─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p2 keep order:false, stats:pseudo" ], "Warn": [ "Warning 1105 Unknown partitions (p0) in optimizer hint /*+ USE_INDEX(t PARTITION(p0, p1) b, c) */" ] }, { "SQL": "select /*+ use_index(t partition(p_non_exist)) */ * from t partition(p1,p2)", "Plan": [ "PartitionUnion 20000.00 root ", "├─TableReader 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p1 keep order:false, stats:pseudo", "└─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p2 keep order:false, stats:pseudo" ], "Warn": [ "Warning 1105 Unknown partitions (p_non_exist) in optimizer hint /*+ USE_INDEX(t PARTITION(p_non_exist)) */" ] }, { "SQL": "select /*+ use_index(t partition(p0, p1) b, c) */ * from t", "Plan": [ "PartitionUnion 30000.00 root ", "├─IndexLookUp 10000.00 root ", "│ ├─IndexFullScan(Build) 10000.00 cop[tikv] table:t, partition:p0, index:b(b) keep order:false, stats:pseudo", "│ └─TableRowIDScan(Probe) 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo", "├─IndexLookUp 10000.00 root ", "│ ├─IndexFullScan(Build) 10000.00 cop[tikv] table:t, partition:p1, index:b(b) keep order:false, stats:pseudo", "│ └─TableRowIDScan(Probe) 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo", "└─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p2 keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "select /*+ ignore_index(t partition(p0, p1) b, c) */ * from t", "Plan": [ "PartitionUnion 30000.00 root ", "├─TableReader 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p0 keep order:false, stats:pseudo", "├─TableReader 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p1 keep order:false, stats:pseudo", "└─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p2 keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "select /*+ hash_join(t1, t2 partition(p0)) */ * from t t1 join t t2 on t1.a = t2.a", "Plan": [ "HashJoin 37500.00 root inner join, equal:[eq(test.t.a, test.t.a)]", "├─PartitionUnion(Build) 30000.00 root ", "│ ├─TableReader 10000.00 root data:TableFullScan", "│ │ └─TableFullScan 10000.00 cop[tiflash] table:t2, partition:p0 keep order:false, stats:pseudo", "│ ├─TableReader 10000.00 root data:TableFullScan", "│ │ └─TableFullScan 10000.00 cop[tiflash] table:t2, partition:p1 keep order:false, stats:pseudo", "│ └─TableReader 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tiflash] table:t2, partition:p2 keep order:false, stats:pseudo", "└─PartitionUnion(Probe) 30000.00 root ", " ├─TableReader 10000.00 root data:TableFullScan", " │ └─TableFullScan 10000.00 cop[tiflash] table:t1, partition:p0 keep order:false, stats:pseudo", " ├─TableReader 10000.00 root data:TableFullScan", " │ └─TableFullScan 10000.00 cop[tiflash] table:t1, partition:p1 keep order:false, stats:pseudo", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tiflash] table:t1, partition:p2 keep order:false, stats:pseudo" ], "Warn": [ "Warning 1105 Optimizer Hint /*+ HASH_JOIN(t1, t2 PARTITION(p0)) */ is inapplicable on specified partitions" ] }, { "SQL": "select /*+ use_index_merge(t partition(p0)) */ * from t where t.b = 1 or t.c = \"8\"", "Plan": [ "PartitionUnion 59.97 root ", "├─IndexMerge 19.99 root ", "│ ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, partition:p0, index:b(b) range:[1,1], keep order:false, stats:pseudo", "│ ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, partition:p0, index:c(c) range:[\"8\",\"8\"], keep order:false, stats:pseudo", "│ └─TableRowIDScan(Probe) 19.99 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo", "├─TableReader 19.99 root data:Selection", "│ └─Selection 19.99 cop[tiflash] or(eq(test.t.b, 1), eq(test.t.c, \"8\"))", "│ └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p1 keep order:false, stats:pseudo", "└─TableReader 19.99 root data:Selection", " └─Selection 19.99 cop[tiflash] or(eq(test.t.b, 1), eq(test.t.c, \"8\"))", " └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p2 keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "select /*+ use_index_merge(t partition(p0, p1) primary, b) */ * from t where t.a = 1 or t.b = 2", "Plan": [ "PartitionUnion 33.00 root ", "├─IndexMerge 11.00 root ", "│ ├─TableRangeScan(Build) 1.00 cop[tikv] table:t, partition:p0 range:[1,1], keep order:false, stats:pseudo", "│ ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, partition:p0, index:b(b) range:[2,2], keep order:false, stats:pseudo", "│ └─TableRowIDScan(Probe) 11.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo", "├─IndexMerge 11.00 root ", "│ ├─TableRangeScan(Build) 1.00 cop[tikv] table:t, partition:p1 range:[1,1], keep order:false, stats:pseudo", "│ ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, partition:p1, index:b(b) range:[2,2], keep order:false, stats:pseudo", "│ └─TableRowIDScan(Probe) 11.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo", "└─TableReader 11.00 root data:Selection", " └─Selection 11.00 cop[tiflash] or(eq(test.t.a, 1), eq(test.t.b, 2))", " └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p2 keep order:false, stats:pseudo" ], "Warn": null }, { "SQL": "select /*+ use_index(t partition(p0) b) */ * from t partition(p0, p1)", "Plan": [ "PartitionUnion 20000.00 root ", "├─IndexLookUp 10000.00 root ", "│ ├─IndexFullScan(Build) 10000.00 cop[tikv] table:t, partition:p0, index:b(b) keep order:false, stats:pseudo", "│ └─TableRowIDScan(Probe) 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo", "└─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tiflash] table:t, partition:p1 keep order:false, stats:pseudo" ], "Warn": null } ] }, { "Name": "TestAccessPathOnClusterIndex", "Cases": [ { "SQL": "select * from t1", "Plan": [ "TableReader 3.00 root data:TableFullScan", "└─TableFullScan 3.00 cop[tikv] table:t1 keep order:false" ], "Res": [ "1 111 1.1000000000 11", "2 222 2.2000000000 12", "3 333 3.3000000000 13" ] }, { "SQL": "select * from t1 where t1.a >= 1 and t1.a < 4", "Plan": [ "TableReader 3.00 root data:TableRangeScan", "└─TableRangeScan 3.00 cop[tikv] table:t1 range:[1,4), keep order:false" ], "Res": [ "1 111 1.1000000000 11", "2 222 2.2000000000 12", "3 333 3.3000000000 13" ] }, { "SQL": "select * from t1 where t1.a = 1 and t1.b < \"333\"", "Plan": [ "TableReader 0.82 root data:TableRangeScan", "└─TableRangeScan 0.82 cop[tikv] table:t1 range:[1 -inf,1 \"333\"), keep order:false" ], "Res": [ "1 111 1.1000000000 11" ] }, { "SQL": "select t1.a, t1.b, t1.c from t1 where t1.c = 3.3", "Plan": [ "IndexReader 1.00 root index:IndexRangeScan", "└─IndexRangeScan 1.00 cop[tikv] table:t1, index:c(c) range:[3.3000000000,3.3000000000], keep order:false" ], "Res": [ "3 333 3.3000000000" ] }, { "SQL": "select t1.b, t1.c from t1 where t1.c = 2.2", "Plan": [ "IndexReader 1.00 root index:IndexRangeScan", "└─IndexRangeScan 1.00 cop[tikv] table:t1, index:c(c) range:[2.2000000000,2.2000000000], keep order:false" ], "Res": [ "222 2.2000000000" ] }, { "SQL": "select /*+ use_index(t1, c) */ * from t1", "Plan": [ "IndexLookUp 3.00 root ", "├─IndexFullScan(Build) 3.00 cop[tikv] table:t1, index:c(c) keep order:false", "└─TableRowIDScan(Probe) 3.00 cop[tikv] table:t1 keep order:false" ], "Res": [ "1 111 1.1000000000 11", "2 222 2.2000000000 12", "3 333 3.3000000000 13" ] }, { "SQL": "select * from t1 use index(c) where t1.c in (2.2, 3.3)", "Plan": [ "IndexLookUp 2.00 root ", "├─IndexRangeScan(Build) 2.00 cop[tikv] table:t1, index:c(c) range:[2.2000000000,2.2000000000], [3.3000000000,3.3000000000], keep order:false", "└─TableRowIDScan(Probe) 2.00 cop[tikv] table:t1 keep order:false" ], "Res": [ "2 222 2.2000000000 12", "3 333 3.3000000000 13" ] }, { "SQL": "select * from t1 where t1.a = 1 order by b", "Plan": [ "TableReader 1.00 root data:TableRangeScan", "└─TableRangeScan 1.00 cop[tikv] table:t1 range:[1,1], keep order:true" ], "Res": [ "1 111 1.1000000000 11" ] }, { "SQL": "select * from t1 order by a, b limit 1", "Plan": [ "Limit 1.00 root offset:0, count:1", "└─TableReader 1.00 root data:Limit", " └─Limit 1.00 cop[tikv] offset:0, count:1", " └─TableFullScan 1.00 cop[tikv] table:t1 keep order:true" ], "Res": [ "1 111 1.1000000000 11" ] }, { "SQL": "select /*+ use_index_merge(t1 primary, c) */ * from t1 where t1.a >= 1 or t1.c = 2.2", "Plan": [ "IndexMerge 3.00 root ", "├─TableRangeScan(Build) 3.00 cop[tikv] table:t1 range:[1,+inf], keep order:false", "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t1, index:c(c) range:[2.2000000000,2.2000000000], keep order:false", "└─TableRowIDScan(Probe) 3.00 cop[tikv] table:t1 keep order:false" ], "Res": [ "1 111 1.1000000000 11", "2 222 2.2000000000 12", "3 333 3.3000000000 13" ] }, { "SQL": "select /*+ use_index_merge(t1 primary, c) */ * from t1 where t1.a = 1 and t1.b = '111' or t1.c = 3.3", "Plan": [ "IndexMerge 1.67 root ", "├─TableRangeScan(Build) 1.00 cop[tikv] table:t1 range:[1 \"111\",1 \"111\"], keep order:false", "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t1, index:c(c) range:[3.3000000000,3.3000000000], keep order:false", "└─TableRowIDScan(Probe) 1.67 cop[tikv] table:t1 keep order:false" ], "Res": [ "1 111 1.1000000000 11", "3 333 3.3000000000 13" ] } ] }, { "Name": "TestIndexJoinOnClusteredIndex", "Cases": [ { "SQL": "select /*+ inl_join(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a", "Plan": [ "IndexJoin 3.00 root inner join, inner:TableReader, outer key:test.t.a, inner key:test.t.a, equal cond:eq(test.t.a, test.t.a)", "├─TableReader(Build) 3.00 root data:TableFullScan", "│ └─TableFullScan 3.00 cop[tikv] table:t1 keep order:false", "└─TableReader(Probe) 1.00 root data:TableRangeScan", " └─TableRangeScan 1.00 cop[tikv] table:t2 range: decided by [test.t.a], keep order:false" ], "Res": [ "1 111 1.1000000000 11 1 111 1.1000000000 11", "2 222 2.2000000000 12 2 222 2.2000000000 12", "3 333 3.3000000000 13 3 333 3.3000000000 13" ] }, { "SQL": "select /*+ inl_merge_join(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a", "Plan": [ "IndexMergeJoin 3.00 root inner join, inner:TableReader, outer key:test.t.a, inner key:test.t.a", "├─TableReader(Build) 3.00 root data:TableFullScan", "│ └─TableFullScan 3.00 cop[tikv] table:t1 keep order:false", "└─TableReader(Probe) 1.00 root data:TableRangeScan", " └─TableRangeScan 1.00 cop[tikv] table:t2 range: decided by [test.t.a], keep order:true" ], "Res": [ "1 111 1.1000000000 11 1 111 1.1000000000 11", "2 222 2.2000000000 12 2 222 2.2000000000 12", "3 333 3.3000000000 13 3 333 3.3000000000 13" ] }, { "SQL": "select /*+ inl_hash_join(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a", "Plan": [ "IndexHashJoin 3.00 root inner join, inner:TableReader, outer key:test.t.a, inner key:test.t.a, equal cond:eq(test.t.a, test.t.a)", "├─TableReader(Build) 3.00 root data:TableFullScan", "│ └─TableFullScan 3.00 cop[tikv] table:t1 keep order:false", "└─TableReader(Probe) 1.00 root data:TableRangeScan", " └─TableRangeScan 1.00 cop[tikv] table:t2 range: decided by [test.t.a], keep order:false" ], "Res": [ "1 111 1.1000000000 11 1 111 1.1000000000 11", "2 222 2.2000000000 12 2 222 2.2000000000 12", "3 333 3.3000000000 13 3 333 3.3000000000 13" ] }, { "SQL": "select /*+ inl_join(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a and t1.b = t2.b", "Plan": [ "IndexJoin 3.00 root inner join, inner:TableReader, outer key:test.t.a, test.t.b, inner key:test.t.a, test.t.b, equal cond:eq(test.t.a, test.t.a), eq(test.t.b, test.t.b)", "├─TableReader(Build) 3.00 root data:TableFullScan", "│ └─TableFullScan 3.00 cop[tikv] table:t1 keep order:false", "└─TableReader(Probe) 1.00 root data:TableRangeScan", " └─TableRangeScan 1.00 cop[tikv] table:t2 range: decided by [test.t.a test.t.b], keep order:false" ], "Res": [ "1 111 1.1000000000 11 1 111 1.1000000000 11", "2 222 2.2000000000 12 2 222 2.2000000000 12", "3 333 3.3000000000 13 3 333 3.3000000000 13" ] }, { "SQL": "select /*+ inl_join(t1, t2) */ * from t t1 join t t2 on t1.c = t2.c", "Plan": [ "IndexJoin 3.00 root inner join, inner:IndexLookUp, outer key:test.t.c, inner key:test.t.c, equal cond:eq(test.t.c, test.t.c)", "├─TableReader(Build) 3.00 root data:Selection", "│ └─Selection 3.00 cop[tikv] not(isnull(test.t.c))", "│ └─TableFullScan 3.00 cop[tikv] table:t1 keep order:false", "└─IndexLookUp(Probe) 1.00 root ", " ├─Selection(Build) 1.00 cop[tikv] not(isnull(test.t.c))", " │ └─IndexRangeScan 1.00 cop[tikv] table:t2, index:c(c) range: decided by [eq(test.t.c, test.t.c)], keep order:false", " └─TableRowIDScan(Probe) 1.00 cop[tikv] table:t2 keep order:false" ], "Res": [ "1 111 1.1000000000 11 1 111 1.1000000000 11", "2 222 2.2000000000 12 2 222 2.2000000000 12", "3 333 3.3000000000 13 3 333 3.3000000000 13" ] }, { "SQL": "select /*+ inl_merge_join(t1,t2) */ t2.a, t2.c, t2.d from t t1 left join t t2 on t1.a = t2.c;", "Plan": [ "IndexMergeJoin 3.00 root left outer join, inner:Projection, outer key:Column#9, inner key:test.t.c", "├─Projection(Build) 3.00 root cast(test.t.a, decimal(20,0) BINARY)->Column#9", "│ └─TableReader 3.00 root data:TableFullScan", "│ └─TableFullScan 3.00 cop[tikv] table:t1 keep order:false", "└─Projection(Probe) 1.00 root test.t.a, test.t.c, test.t.d", " └─IndexLookUp 1.00 root ", " ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t2, index:c(c) range: decided by [eq(test.t.c, Column#9)], keep order:true", " └─TableRowIDScan(Probe) 1.00 cop[tikv] table:t2 keep order:false" ], "Res": [ " ", " ", " " ] } ] }, { "Name": "TestPartitionExplain", "Cases": [ { "SQL": "select * from pt where c > 10", "Plan": [ "TableReader_7 3333.33 root partition:dual data:Selection_6", "└─Selection_6 3333.33 cop[tikv] gt(test.pt.c, 10)", " └─TableFullScan_5 10000.00 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select * from pt where c > 8", "Plan": [ "TableReader_7 3333.33 root partition:p2 data:Selection_6", "└─Selection_6 3333.33 cop[tikv] gt(test.pt.c, 8)", " └─TableFullScan_5 10000.00 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select * from pt where c < 2 or c >= 9", "Plan": [ "TableReader_7 6656.67 root partition:p0,p2 data:Selection_6", "└─Selection_6 6656.67 cop[tikv] or(lt(test.pt.c, 2), ge(test.pt.c, 9))", " └─TableFullScan_5 10000.00 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select c from pt", "Plan": [ "IndexReader_7 10000.00 root partition:all index:IndexFullScan_6", "└─IndexFullScan_6 10000.00 cop[tikv] table:pt, index:i_c(c) keep order:false, stats:pseudo" ] }, { "SQL": "select c from pt where c > 10", "Plan": [ "IndexReader_6 3333.33 root partition:dual index:IndexRangeScan_5", "└─IndexRangeScan_5 3333.33 cop[tikv] table:pt, index:i_c(c) range:(10,+inf], keep order:false, stats:pseudo" ] }, { "SQL": "select c from pt where c > 8", "Plan": [ "IndexReader_6 3333.33 root partition:p2 index:IndexRangeScan_5", "└─IndexRangeScan_5 3333.33 cop[tikv] table:pt, index:i_c(c) range:(8,+inf], keep order:false, stats:pseudo" ] }, { "SQL": "select c from pt where c < 2 or c >= 9", "Plan": [ "IndexReader_6 6656.67 root partition:p0,p2 index:IndexRangeScan_5", "└─IndexRangeScan_5 6656.67 cop[tikv] table:pt, index:i_c(c) range:[-inf,2), [9,+inf], keep order:false, stats:pseudo" ] }, { "SQL": "select /*+ use_index(pt, i_id) */ * from pt", "Plan": [ "IndexLookUp_6 10000.00 root partition:all ", "├─IndexFullScan_4(Build) 10000.00 cop[tikv] table:pt, index:i_id(id) keep order:false, stats:pseudo", "└─TableRowIDScan_5(Probe) 10000.00 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select /*+ use_index(pt, i_id) */ * from pt where id < 4 and c > 10", "Plan": [ "IndexLookUp_8 1107.78 root partition:dual ", "├─IndexRangeScan_5(Build) 3323.33 cop[tikv] table:pt, index:i_id(id) range:[-inf,4), keep order:false, stats:pseudo", "└─Selection_7(Probe) 1107.78 cop[tikv] gt(test.pt.c, 10)", " └─TableRowIDScan_6 3323.33 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select /*+ use_index(pt, i_id) */ * from pt where id < 10 and c > 8", "Plan": [ "IndexLookUp_8 1107.78 root partition:p2 ", "├─IndexRangeScan_5(Build) 3323.33 cop[tikv] table:pt, index:i_id(id) range:[-inf,10), keep order:false, stats:pseudo", "└─Selection_7(Probe) 1107.78 cop[tikv] gt(test.pt.c, 8)", " └─TableRowIDScan_6 3323.33 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select /*+ use_index(pt, i_id) */ * from pt where id < 10 and c < 2 or c >= 9", "Plan": [ "IndexLookUp_8 5325.33 root partition:p0,p2 ", "├─IndexFullScan_5(Build) 10000.00 cop[tikv] table:pt, index:i_id(id) keep order:false, stats:pseudo", "└─Selection_7(Probe) 5325.33 cop[tikv] or(and(lt(test.pt.id, 10), lt(test.pt.c, 2)), ge(test.pt.c, 9))", " └─TableRowIDScan_6 10000.00 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select * from pt partition (p0) where c > 8", "Plan": [ "TableReader_7 3333.33 root partition:dual data:Selection_6", "└─Selection_6 3333.33 cop[tikv] gt(test.pt.c, 8)", " └─TableFullScan_5 10000.00 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select c from pt partition (p0, p2) where c > 8", "Plan": [ "IndexReader_6 3333.33 root partition:p2 index:IndexRangeScan_5", "└─IndexRangeScan_5 3333.33 cop[tikv] table:pt, index:i_c(c) range:(8,+inf], keep order:false, stats:pseudo" ] }, { "SQL": "select /*+ use_index(pt, i_id) */ * from pt partition (p1, p2) where c < 3 and id = 5", "Plan": [ "IndexLookUp_8 3.32 root partition:dual ", "├─IndexRangeScan_5(Build) 10.00 cop[tikv] table:pt, index:i_id(id) range:[5,5], keep order:false, stats:pseudo", "└─Selection_7(Probe) 3.32 cop[tikv] lt(test.pt.c, 3)", " └─TableRowIDScan_6 10.00 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select * from pt where id = 4 or c < 7", "Plan": [ "IndexMerge_11 3330.01 root partition:all ", "├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:pt, index:i_id(id) range:[4,4], keep order:false, stats:pseudo", "├─IndexRangeScan_9(Build) 3323.33 cop[tikv] table:pt, index:i_c(c) range:[-inf,7), keep order:false, stats:pseudo", "└─TableRowIDScan_10(Probe) 3330.01 cop[tikv] table:pt keep order:false, stats:pseudo" ] }, { "SQL": "select * from pt where id > 4 or c = 7", "Plan": [ "IndexMerge_11 3340.00 root partition:all ", "├─IndexRangeScan_8(Build) 3333.33 cop[tikv] table:pt, index:i_id(id) range:(4,+inf], keep order:false, stats:pseudo", "├─IndexRangeScan_9(Build) 10.00 cop[tikv] table:pt, index:i_c(c) range:[7,7], keep order:false, stats:pseudo", "└─TableRowIDScan_10(Probe) 3340.00 cop[tikv] table:pt keep order:false, stats:pseudo" ] } ] }, { "Name": "TestInvalidHint", "Cases": [ { "SQL": "explain format = 'brief' select /*+ use_index_merge(tt) */ * from tt where a=10 or a=20;", "Plan": [ "IndexReader 20.00 root index:IndexRangeScan", "└─IndexRangeScan 20.00 cop[tikv] table:tt, index:a(a) range:[10,10], [20,20], keep order:false, stats:pseudo" ], "Warnings": [ "Warning 1105 IndexMerge is inapplicable or disabled" ] }, { "SQL": "explain format = 'brief' select /*+ use_index_merge(tt) */ * from tt where a=15 or (a < 10 or a > 20);", "Plan": [ "IndexReader 6666.67 root index:IndexRangeScan", "└─IndexRangeScan 6666.67 cop[tikv] table:tt, index:a(a) range:[-inf,10), [15,15], (20,+inf], keep order:false, stats:pseudo" ], "Warnings": [ "Warning 1105 IndexMerge is inapplicable or disabled" ] } ] }, { "Name": "TestApproxPercentile", "Cases": [ { "SQL": "select approx_percentile(a, 50) from t", "Plan": [ "HashAgg_5 1.00 root funcs:approx_percentile(test.t.a, 50)->Column#4", "└─TableReader_11 10000.00 root data:TableFullScan_10", " └─TableFullScan_10 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Res": [ "3" ] }, { "SQL": "select approx_percentile(a, 10) from t", "Plan": [ "HashAgg_5 1.00 root funcs:approx_percentile(test.t.a, 10)->Column#4", "└─TableReader_11 10000.00 root data:TableFullScan_10", " └─TableFullScan_10 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Res": [ "1" ] }, { "SQL": "select approx_percentile(a, 10+70) from t", "Plan": [ "HashAgg_5 1.00 root funcs:approx_percentile(test.t.a, 80)->Column#4", "└─TableReader_11 10000.00 root data:TableFullScan_10", " └─TableFullScan_10 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Res": [ "4" ] }, { "SQL": "select approx_percentile(a, 10*10) from t", "Plan": [ "HashAgg_5 1.00 root funcs:approx_percentile(test.t.a, 100)->Column#4", "└─TableReader_11 10000.00 root data:TableFullScan_10", " └─TableFullScan_10 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Res": [ "5" ] }, { "SQL": "select approx_percentile(a, 50) from t group by b order by b", "Plan": [ "Projection_6 8000.00 root Column#4", "└─Sort_7 8000.00 root test.t.b", " └─HashAgg_9 8000.00 root group by:test.t.b, funcs:approx_percentile(test.t.a, 50)->Column#4, funcs:firstrow(test.t.b)->test.t.b", " └─TableReader_13 10000.00 root data:TableFullScan_12", " └─TableFullScan_12 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], "Res": [ "1", "4" ] } ] }, { "Name": "TestConvertRangeToPoint", "Cases": [ { "SQL": "explain format = 'brief' select * from t0 where a > 1 and a < 3 order by b limit 2", "Plan": [ "Limit 2.00 root offset:0, count:2", "└─IndexReader 2.00 root index:Limit", " └─Limit 2.00 cop[tikv] offset:0, count:2", " └─IndexRangeScan 2.50 cop[tikv] table:t0, index:a(a, b) range:[2,2], keep order:true, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select * from t1 where a >= 2 and a <= 2 and b = 2 and c > 2", "Plan": [ "IndexReader 0.33 root index:IndexRangeScan", "└─IndexRangeScan 0.33 cop[tikv] table:t1, index:a(a, b, c) range:(2 2 2,2 2 +inf], keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select * from t2 where a >= 2.5 and a <= 2.5 order by b limit 2", "Plan": [ "Limit 2.00 root offset:0, count:2", "└─IndexReader 2.00 root index:Limit", " └─Limit 2.00 cop[tikv] offset:0, count:2", " └─IndexRangeScan 2.00 cop[tikv] table:t2, index:a(a, b) range:[2.5,2.5], keep order:true, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select * from t3 where a >= 'a' and a <= 'a' and b = 'b' and c > 'c'", "Plan": [ "IndexReader 0.33 root index:IndexRangeScan", "└─IndexRangeScan 0.33 cop[tikv] table:t3, index:a(a, b, c) range:(\"a\" \"b\" \"c\",\"a\" \"b\" +inf], keep order:false, stats:pseudo" ] } ] }, { "Name": "TestIssue22105", "Cases": [ { "SQL": "explain format = 'brief' SELECT /*+ use_index_merge(t1)*/ COUNT(*) FROM t1 WHERE (key4=42 AND key6 IS NOT NULL) OR (key1=4 AND key3=6)", "Plan": [ "StreamAgg 1.00 root funcs:count(1)->Column#10", "└─IndexMerge 0.02 root ", " ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t1, index:i4(key4) range:[42,42], keep order:false, stats:pseudo", " ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t1, index:i1(key1) range:[4,4], keep order:false, stats:pseudo", " └─Selection(Probe) 0.02 cop[tikv] or(and(eq(test.t1.key4, 42), not(isnull(test.t1.key6))), and(eq(test.t1.key1, 4), eq(test.t1.key3, 6)))", " └─TableRowIDScan 19.99 cop[tikv] table:t1 keep order:false, stats:pseudo" ] } ] }, { "Name": "TestReorderSimplifiedOuterJoins", "Cases": [ { "SQL": "explain format = 'brief' SELECT t1.pk FROM t1 INNER JOIN t2 ON t1.col1 = t2.pk INNER JOIN t3 ON t1.col3 = t3.pk WHERE t2.col1 IN ('a' , 'b') AND t3.keycol = 'c' AND t1.col2 = 'a' AND t1.col1 != 'abcdef' AND t1.col1 != 'aaaaaa'", "Plan": [ "IndexJoin 13.81 root inner join, inner:IndexLookUp, outer key:test.t1.col1, inner key:test.t2.pk, equal cond:eq(test.t1.col1, test.t2.pk)", "├─IndexJoin(Build) 12.50 root inner join, inner:IndexLookUp, outer key:test.t3.pk, inner key:test.t1.col3, equal cond:eq(test.t3.pk, test.t1.col3)", "│ ├─IndexLookUp(Build) 10.00 root ", "│ │ ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t3, index:keycol(keycol, pad1, pad2) range:[\"c\",\"c\"], keep order:false, stats:pseudo", "│ │ └─TableRowIDScan(Probe) 10.00 cop[tikv] table:t3 keep order:false, stats:pseudo", "│ └─IndexLookUp(Probe) 1.25 root ", "│ ├─Selection(Build) 1.81 cop[tikv] not(isnull(test.t1.col3))", "│ │ └─IndexRangeScan 1.81 cop[tikv] table:t1, index:col2(col2, col3) range: decided by [eq(test.t1.col3, test.t3.pk) eq(test.t1.col2, a)], keep order:false, stats:pseudo", "│ └─Selection(Probe) 1.25 cop[tikv] ne(test.t1.col1, \"aaaaaa\"), ne(test.t1.col1, \"abcdef\"), not(isnull(test.t1.col1))", "│ └─TableRowIDScan 1.81 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─IndexLookUp(Probe) 1.00 root ", " ├─Selection(Build) 1.00 cop[tikv] ne(test.t2.pk, \"aaaaaa\"), ne(test.t2.pk, \"abcdef\")", " │ └─IndexRangeScan 1.00 cop[tikv] table:t2, index:PRIMARY(pk) range: decided by [eq(test.t2.pk, test.t1.col1)], keep order:false, stats:pseudo", " └─Selection(Probe) 1.00 cop[tikv] in(test.t2.col1, \"a\", \"b\")", " └─TableRowIDScan 1.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' SELECT t1.pk FROM t1 LEFT JOIN t2 ON t1.col1 = t2.pk LEFT JOIN t3 ON t1.col3 = t3.pk WHERE t2.col1 IN ('a' , 'b') AND t3.keycol = 'c' AND t1.col2 = 'a' AND t1.col1 != 'abcdef' AND t1.col1 != 'aaaaaa'", "Plan": [ "IndexJoin 13.81 root inner join, inner:IndexLookUp, outer key:test.t1.col1, inner key:test.t2.pk, equal cond:eq(test.t1.col1, test.t2.pk)", "├─IndexJoin(Build) 12.50 root inner join, inner:IndexLookUp, outer key:test.t3.pk, inner key:test.t1.col3, equal cond:eq(test.t3.pk, test.t1.col3)", "│ ├─IndexLookUp(Build) 10.00 root ", "│ │ ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t3, index:keycol(keycol, pad1, pad2) range:[\"c\",\"c\"], keep order:false, stats:pseudo", "│ │ └─TableRowIDScan(Probe) 10.00 cop[tikv] table:t3 keep order:false, stats:pseudo", "│ └─IndexLookUp(Probe) 1.25 root ", "│ ├─Selection(Build) 1.81 cop[tikv] not(isnull(test.t1.col3))", "│ │ └─IndexRangeScan 1.81 cop[tikv] table:t1, index:col2(col2, col3) range: decided by [eq(test.t1.col3, test.t3.pk) eq(test.t1.col2, a)], keep order:false, stats:pseudo", "│ └─Selection(Probe) 1.25 cop[tikv] ne(test.t1.col1, \"aaaaaa\"), ne(test.t1.col1, \"abcdef\"), not(isnull(test.t1.col1))", "│ └─TableRowIDScan 1.81 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─IndexLookUp(Probe) 1.00 root ", " ├─Selection(Build) 1.00 cop[tikv] ne(test.t2.pk, \"aaaaaa\"), ne(test.t2.pk, \"abcdef\")", " │ └─IndexRangeScan 1.00 cop[tikv] table:t2, index:PRIMARY(pk) range: decided by [eq(test.t2.pk, test.t1.col1)], keep order:false, stats:pseudo", " └─Selection(Probe) 1.00 cop[tikv] in(test.t2.col1, \"a\", \"b\")", " └─TableRowIDScan 1.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ] } ] }, { "Name": "TestDecorrelateInnerJoinInSubquery", "Cases": [ { "SQL": "explain format = 'brief' select * from t where exists (select 1 from t t1 join t t2 where t1.a = t2.a and t1.a = t.a)", "Plan": [ "HashJoin 8000.00 root semi join, equal:[eq(test.t.a, test.t.a)]", "├─HashJoin(Build) 12500.00 root inner join, equal:[eq(test.t.a, test.t.a)]", "│ ├─TableReader(Build) 10000.00 root data:TableFullScan", "│ │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", "│ └─TableReader(Probe) 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─TableReader(Probe) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] }, { "SQL": "explain format = 'brief' select * from t where exists (select 1 from t t1 join t t2 on t1.a = t2.a and t1.a = t.a)", "Plan": [ "HashJoin 8000.00 root semi join, equal:[eq(test.t.a, test.t.a)]", "├─HashJoin(Build) 12500.00 root inner join, equal:[eq(test.t.a, test.t.a)]", "│ ├─TableReader(Build) 10000.00 root data:TableFullScan", "│ │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", "│ └─TableReader(Probe) 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─TableReader(Probe) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] } ] }, { "Name": "TestMultiColMaxOneRow", "Cases": [ { "SQL": "select (select c from t2 where t2.a = t1.a and t2.b = 1) from t1", "Plan": [ "HashJoin 10000.00 root left outer join, equal:[eq(test.t1.a, test.t2.a)]", "├─TableReader(Build) 10.00 root data:Selection", "│ └─Selection 10.00 cop[tikv] eq(test.t2.b, 1)", "│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", "└─TableReader(Probe) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "select (select c from t2 where t2.a = t1.a and (t2.b = 1 or t2.b = 2)) from t1", "Plan": [ "Projection 10000.00 root test.t2.c", "└─Apply 10000.00 root CARTESIAN left outer join", " ├─TableReader(Build) 10000.00 root data:TableFullScan", " │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", " └─MaxOneRow(Probe) 1.00 root ", " └─IndexLookUp 0.02 root ", " ├─Selection(Build) 0.02 cop[tikv] or(eq(test.t2.b, 1), eq(test.t2.b, 2))", " │ └─IndexRangeScan 10.00 cop[tikv] table:t2, index:PRIMARY(a, b) range: decided by [eq(test.t2.a, test.t1.a)], keep order:false, stats:pseudo", " └─TableRowIDScan(Probe) 0.02 cop[tikv] table:t2 keep order:false, stats:pseudo" ] } ] }, { "Name": "TestIssue24095", "Cases": [ { "SQL": "select count(*) from t join (select t.id, t.value v1 from t join t t1 on t.id = t1.id order by t.value limit 1) v on v.id = t.id and v.v1 = t.value;", "Plan": [ "StreamAgg 1.00 root funcs:count(1)->Column#10", "└─HashJoin 1.00 root inner join, equal:[eq(test.t.id, test.t.id) eq(test.t.value, test.t.value)]", " ├─Selection(Build) 0.80 root not(isnull(test.t.id)), not(isnull(test.t.value))", " │ └─TopN 1.00 root test.t.value, offset:0, count:1", " │ └─HashJoin 12487.50 root inner join, equal:[eq(test.t.id, test.t.id)]", " │ ├─TableReader(Build) 9990.00 root data:Selection", " │ │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.id))", " │ │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", " │ └─TableReader(Probe) 9990.00 root data:Selection", " │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.id))", " │ └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo", " └─TableReader(Probe) 9980.01 root data:Selection", " └─Selection 9980.01 cop[tikv] not(isnull(test.t.id)), not(isnull(test.t.value))", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] } ] }, { "Name": "TestSequenceAsDataSource", "Cases": [ { "SQL": "select 1 from s1", "Plan": [ "Projection 1.00 root 1->Column#1", "└─TableDual 1.00 root rows:1" ] }, { "SQL": "select count(1) from s1", "Plan": [ "StreamAgg 1.00 root funcs:count(1)->Column#1", "└─TableDual 1.00 root rows:1" ] }, { "SQL": "select count(*) from s1", "Plan": [ "StreamAgg 1.00 root funcs:count(1)->Column#1", "└─TableDual 1.00 root rows:1" ] }, { "SQL": "select sum(1) from s1", "Plan": [ "StreamAgg 1.00 root funcs:sum(1)->Column#1", "└─TableDual 1.00 root rows:1" ] }, { "SQL": "select count(1) as cnt from s1 union select count(1) as cnt from s2", "Plan": [ "HashAgg 2.00 root group by:Column#3, funcs:firstrow(Column#3)->Column#3", "└─Union 2.00 root ", " ├─StreamAgg 1.00 root funcs:count(1)->Column#1", " │ └─TableDual 1.00 root rows:1", " └─StreamAgg 1.00 root funcs:count(1)->Column#2", " └─TableDual 1.00 root rows:1" ] } ] }, { "Name": "TestIsMatchProp", "Cases": [ { "SQL": "select a, b, c from t1 where a > 3 and b = 4 order by a, c", "Plan": [ "IndexReader 3.33 root index:Selection", "└─Selection 3.33 cop[tikv] eq(test.t1.b, 4)", " └─IndexRangeScan 3333.33 cop[tikv] table:t1, index:idx_a_b_c(a, b, c) range:(3,+inf], keep order:true, stats:pseudo" ] }, { "SQL": "select * from t2 where a = 1 and c = 2 order by b, d", "Plan": [ "IndexReader 0.01 root index:Selection", "└─Selection 0.01 cop[tikv] eq(test.t2.c, 2)", " └─IndexRangeScan 10.00 cop[tikv] table:t2, index:idx_a_b_c_d(a, b, c, d) range:[1,1], keep order:true, stats:pseudo" ] }, { "SQL": "select a, b, c from t1 where (a = 1 and b = 1 and c = 1) or (a = 1 and b = 1 and c = 2) order by c", "Plan": [ "IndexReader 0.03 root index:IndexRangeScan", "└─IndexRangeScan 0.03 cop[tikv] table:t1, index:idx_a_b_c(a, b, c) range:[1 1 1,1 1 2], keep order:true, stats:pseudo" ] }, { "SQL": "select a, b, c from t1 where (a = 1 and b = 1 and c < 3) or (a = 1 and b = 1 and c > 6) order by c", "Plan": [ "IndexReader 0.67 root index:IndexRangeScan", "└─IndexRangeScan 0.67 cop[tikv] table:t1, index:idx_a_b_c(a, b, c) range:[1 1 -inf,1 1 3), (1 1 6,1 1 +inf], keep order:true, stats:pseudo" ] }, { "SQL": "select * from t2 where ((a = 1 and b = 1 and d < 3) or (a = 1 and b = 1 and d > 6)) and c = 3 order by d", "Plan": [ "IndexReader 0.00 root index:Selection", "└─Selection 0.00 cop[tikv] eq(test.t2.c, 3), or(and(eq(test.t2.a, 1), and(eq(test.t2.b, 1), lt(test.t2.d, 3))), and(eq(test.t2.a, 1), and(eq(test.t2.b, 1), gt(test.t2.d, 6))))", " └─IndexRangeScan 10.00 cop[tikv] table:t2, index:idx_a_b_c_d(a, b, c, d) range:[1,1], keep order:true, stats:pseudo" ] } ] }, { "Name": "TestHeuristicIndexSelection", "Cases": [ { "SQL": "select * from t1 where a = 3 or a = 5", "Plan": [ "Batch_Point_Get_5 2.00 12.53 root table:t1 handle:[3 5], keep order:false, desc:false" ], "Warnings": [ "Note 1105 handle of t1 is selected since the path only has point ranges" ] }, { "SQL": "select f, g from t1 where f = 2 and g in (3, 4, 5)", "Plan": [ "Batch_Point_Get_5 3.00 11.40 root table:t1, index:f_g(f, g) keep order:false, desc:false" ], "Warnings": [ "Note 1105 unique index f_g of t1 is selected since the path only has point ranges with single scan" ] }, { "SQL": "select * from t1 where c = 1 and (d = 2 or d = 3) and e in (4, 5)", "Plan": [ "Batch_Point_Get_5 4.00 27.20 root table:t1, index:c_d_e(c, d, e) keep order:false, desc:false" ], "Warnings": [ "Note 1105 unique index c_d_e of t1 is selected since the path only has point ranges with double scan" ] }, { "SQL": "select f, g from t1 where f = 2 and g > 3", "Plan": [ "IndexReader_6 33.33 160.78 root index:IndexRangeScan_5", "└─IndexRangeScan_5 33.33 1870.00 cop[tikv] table:t1, index:f_g(f, g) range:(2 3,2 +inf], keep order:false, stats:pseudo" ], "Warnings": [ "Note 1105 unique index f_g of t1 is selected since the path only fetches limited number of rows with single scan" ] }, { "SQL": "select a, b, c from t2 where a = 1 and b = 2 and c in (1, 2, 3, 4, 5)", "Plan": [ "Selection_6 0.01 0.00 root eq(test.t2.b, 2), in(test.t2.c, 1, 2, 3, 4, 5)", "└─Point_Get_5 1.00 8.60 root table:t2, index:idx_a(a) " ], "Warnings": [ "Note 1105 unique index idx_a of t2 is selected since the path only has point ranges with double scan" ] }, { "SQL": "select * from t3 where (a = 1 or a = 3) and b = 'xx'", "Plan": [ "Batch_Point_Get_5 2.00 7.60 root table:t3, clustered index:PRIMARY(a, b) keep order:false, desc:false" ], "Warnings": [ "Note 1105 handle of t3 is selected since the path only has point ranges" ] }, { "SQL": "select * from t4 where (a = 1 or a = 3) and b = 'xx'", "Plan": [ "Batch_Point_Get_5 2.00 10.00 root table:t4, index:PRIMARY(a, b) keep order:false, desc:false" ], "Warnings": [ "Note 1105 unique index PRIMARY of t4 is selected since the path only has point ranges with double scan" ] }, { "SQL": "select a, b from t3 where (a = 1 or a = 3) and b = 'xx'", "Plan": [ "Batch_Point_Get_5 2.00 7.60 root table:t3, clustered index:PRIMARY(a, b) keep order:false, desc:false" ], "Warnings": [ "Note 1105 handle of t3 is selected since the path only has point ranges" ] }, { "SQL": "select a, b from t4 where (a = 1 or a = 3) and b = 'xx'", "Plan": [ "Batch_Point_Get_5 2.00 7.60 root table:t4, index:PRIMARY(a, b) keep order:false, desc:false" ], "Warnings": [ "Note 1105 unique index PRIMARY of t4 is selected since the path only has point ranges with single scan" ] }, { "SQL": "update t1 set b = 2 where a = 4 or a = 6", "Plan": [ "Update_4 N/A N/A root N/A", "└─Batch_Point_Get_6 2.00 12.53 root table:t1 handle:[4 6], keep order:false, desc:false" ], "Warnings": [ "Note 1105 handle of t1 is selected since the path only has point ranges" ] }, { "SQL": "delete from t1 where f = 2 and g in (3, 4)", "Plan": [ "Delete_4 N/A N/A root N/A", "└─Selection_7 2.00 0.00 root in(test.t1.g, 3, 4)", " └─Point_Get_6 1.00 9.80 root table:t1, index:f(f) " ], "Warnings": [ "Note 1105 unique index f of t1 is selected since the path only has point ranges with double scan" ] }, { "SQL": "insert into t3 select a, b, c from t1 where f = 2", "Plan": [ "Insert_1 N/A N/A root N/A", "└─Projection_6 1.00 25.40 root test.t1.a, test.t1.b, test.t1.c", " └─Point_Get_7 1.00 6.80 root table:t1, index:f(f) " ], "Warnings": [ "Note 1105 unique index f of t1 is selected since the path only has point ranges with double scan" ] }, { "SQL": "replace into t3 select a, b, c from t1 where a = 3", "Plan": [ "Insert_1 N/A N/A root N/A", "└─Point_Get_7 1.00 6.27 root table:t1 handle:3" ], "Warnings": [ "Note 1105 handle of t1 is selected since the path only has point ranges" ] } ] }, { "Name": "TestOutputSkylinePruningInfo", "Cases": [ { "SQL": "select * from t where a > 1 order by f", "Plan": [ "IndexLookUp_14 3333.33 139413.67 root ", "├─Selection_13(Build) 3333.33 0.00 cop[tikv] gt(test.t.a, 1)", "│ └─IndexFullScan_11 10000.00 555020.00 cop[tikv] table:t, index:f(f) keep order:true, stats:pseudo", "└─TableRowIDScan_12(Probe) 3333.33 555020.00 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: [{test.t.f asc}], TaskTp: rootTask}" ] }, { "SQL": "select * from t where f > 1", "Plan": [ "TableReader_7 3333.33 88640.22 root data:Selection_6", "└─Selection_6 3333.33 1140020.00 cop[tikv] gt(test.t.f, 1)", " └─TableFullScan_5 10000.00 1110020.00 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}" ] }, { "SQL": "select f from t where f > 1", "Plan": [ "IndexReader_6 3333.33 11140.22 root index:IndexRangeScan_5", "└─IndexRangeScan_5 3333.33 140020.00 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}" ] }, { "SQL": "select * from t where f > 3 and g = 5", "Plan": [ "IndexLookUp_15 3.33 215.74 root ", "├─IndexRangeScan_12(Build) 10.00 590.00 cop[tikv] table:t, index:g(g) range:[5,5], keep order:false, stats:pseudo", "└─Selection_14(Probe) 3.33 0.00 cop[tikv] gt(test.t.f, 3)", " └─TableRowIDScan_13 10.00 590.00 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}" ] }, { "SQL": "select * from t where g = 5 order by f", "Plan": [ "Sort_5 10.00 362.68 root test.t.f", "└─IndexLookUp_13 10.00 239.01 root ", " ├─IndexRangeScan_11(Build) 10.00 590.00 cop[tikv] table:t, index:g(g) range:[5,5], keep order:false, stats:pseudo", " └─TableRowIDScan_12(Probe) 10.00 590.00 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}" ] }, { "SQL": "select * from t where d = 3 order by c, e", "Plan": [ "IndexLookUp_15 10.00 57230.78 root ", "├─Selection_14(Build) 10.00 0.00 cop[tikv] eq(test.t.d, 3)", "│ └─IndexFullScan_12 10000.00 825020.00 cop[tikv] table:t, index:c_d_e(c, d, e) keep order:true, stats:pseudo", "└─TableRowIDScan_13(Probe) 10.00 825020.00 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}" ] } ] }, { "Name": "TestPreferRangeScanForUnsignedIntHandle", "Cases": [ { "SQL": "set tidb_opt_prefer_range_scan = 0", "Plan": null, "Warnings": null }, { "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 215.00 cop[tikv] gt(test.t.b, 5)", " └─TableFullScan_5 5.00 200.00 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 215.00 cop[tikv] offset:0, count:1", " └─Selection_22 0.00 215.00 cop[tikv] eq(test.t.b, 6)", " └─TableFullScan_21 5.00 200.00 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 215.00 cop[tikv] offset:0, count:1", " └─Selection_11 0.00 215.00 cop[tikv] eq(test.t.b, 6)", " └─TableFullScan_10 5.00 200.00 cop[tikv] table:t keep order:false" ], "Warnings": null }, { "SQL": "set tidb_opt_prefer_range_scan = 1", "Plan": null, "Warnings": null }, { "SQL": "explain format = 'verbose' select * from t where b > 5", "Plan": [ "IndexLookUp_7 3.00 64.81 root ", "├─IndexRangeScan_5(Build) 3.00 191.00 cop[tikv] table:t, index:idx_b(b) range:(5,+inf], keep order:false", "└─TableRowIDScan_6(Probe) 3.00 191.00 cop[tikv] table:t keep order:false" ], "Warnings": [ "Note 1105 [idx_b] remain after pruning paths for t given Prop{SortItems: [], TaskTp: rootTask}" ] }, { "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", " │ └─IndexRangeScan_13 0.00 20.00 cop[tikv] table:t, index:idx_b(b) range:[6,6], keep order:false", " └─TableRowIDScan_14(Probe) 0.00 20.00 cop[tikv] table:t keep order:false" ], "Warnings": [ "Note 1105 [idx_b] remain after pruning paths for t given Prop{SortItems: [], TaskTp: copDoubleReadTask}" ] }, { "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)", "├─Limit_12(Build) 0.00 20.00 cop[tikv] offset:0, count:1", "│ └─IndexRangeScan_10 0.00 20.00 cop[tikv] table:t, index:idx_b(b) range:[6,6], keep order:false", "└─TableRowIDScan_11(Probe) 0.00 20.00 cop[tikv] table:t keep order:false" ], "Warnings": [ "Note 1105 [idx_b] remain after pruning paths for t given Prop{SortItems: [], TaskTp: copDoubleReadTask}" ] } ] }, { "Name": "TestIssue27083", "Cases": [ { "SQL": "select * from t use index (idx_b) where b = 2 limit 1", "Plan": [ "IndexLookUp 1.00 root limit embedded(offset:0, count:1)", "├─Limit(Build) 1.00 cop[tikv] offset:0, count:1", "│ └─IndexRangeScan 1.00 cop[tikv] table:t, index:idx_b(b) range:[2,2], keep order:false", "└─TableRowIDScan(Probe) 1.00 cop[tikv] table:t keep order:false" ] } ] }, { "Name": "TestGroupBySetVar", "Cases": [ { "SQL": "select floor(dt.rn/2) rownum, count(c1) from (select @rownum := @rownum + 1 rn, c1 from (select @rownum := -1) drn, t1) dt group by floor(dt.rn/2) order by rownum;", "Plan": [ "Sort 1.00 root Column#6", "└─Projection 1.00 root floor(div(cast(Column#4, decimal(20,0) BINARY), 2))->Column#6, Column#5", " └─HashAgg 1.00 root group by:Column#13, funcs:count(Column#11)->Column#5, funcs:firstrow(Column#12)->Column#4", " └─Projection 10000.00 root test.t1.c1, Column#4, floor(div(cast(Column#4, decimal(20,0) BINARY), 2))->Column#13", " └─Projection 10000.00 root setvar(rownum, plus(getvar(rownum), 1))->Column#4, test.t1.c1", " └─HashJoin 10000.00 root CARTESIAN inner join", " ├─Projection(Build) 1.00 root setvar(rownum, -1)->Column#1", " │ └─TableDual 1.00 root rows:1", " └─TableReader(Probe) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" ] }, { "SQL": "select @n:=@n+1 as e from ta group by e", "Plan": [ "Projection 1.00 root setvar(n, plus(getvar(n), 1))->Column#4", "└─HashAgg 1.00 root group by:Column#8, funcs:firstrow(1)->Column#7", " └─Projection 10000.00 root setvar(n, plus(cast(getvar(n), double BINARY), 1))->Column#8", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo" ] }, { "SQL": "select @n:=@n+a as e from ta group by e", "Plan": [ "Projection 8000.00 root setvar(n, plus(getvar(n), cast(test.ta.a, double BINARY)))->Column#4", "└─HashAgg 8000.00 root group by:Column#7, funcs:firstrow(Column#6)->test.ta.a", " └─Projection 10000.00 root test.ta.a, setvar(n, plus(getvar(n), cast(test.ta.a, double BINARY)))->Column#7", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo" ] }, { "SQL": "select * from (select @n:=@n+1 as e from ta) tt group by e", "Plan": [ "HashAgg 1.00 root group by:Column#4, funcs:firstrow(Column#4)->Column#4", "└─Projection 10000.00 root setvar(n, plus(getvar(n), 1))->Column#4", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo" ] }, { "SQL": "select * from (select @n:=@n+a as e from ta) tt group by e", "Plan": [ "HashAgg 8000.00 root group by:Column#4, funcs:firstrow(Column#4)->Column#4", "└─Projection 10000.00 root setvar(n, plus(getvar(n), cast(test.ta.a, double BINARY)))->Column#4", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo" ] }, { "SQL": "select a from ta group by @n:=@n+1", "Plan": [ "HashAgg 1.00 root group by:Column#5, funcs:firstrow(Column#4)->test.ta.a", "└─Projection 10000.00 root test.ta.a, setvar(n, plus(getvar(n), 1))->Column#5", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo" ] }, { "SQL": "select a from ta group by @n:=@n+a", "Plan": [ "HashAgg 8000.00 root group by:Column#5, funcs:firstrow(Column#4)->test.ta.a", "└─Projection 10000.00 root test.ta.a, setvar(n, plus(getvar(n), cast(test.ta.a, double BINARY)))->Column#5", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:ta keep order:false, stats:pseudo" ] } ] } ]