Files
tidb/planner/core/testdata/integration_suite_out.json

1486 lines
73 KiB
JSON

[
{
"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, stats:pseudo"
]
},
{
"SQL": "explain format = 'brief' select * from tbl use index(idx_b_c) where b > 1 order by b desc limit 2,1",
"Plan": [
"Projection 1.00 root test.tbl.a, test.tbl.b, test.tbl.c",
"└─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:true, desc",
" └─TableRowIDScan(Probe) 1.00 cop[tikv] table:tbl keep order:false, stats:pseudo"
]
},
{
"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, stats:pseudo"
]
},
{
"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 7992.00 root data:Selection",
" │ └─Selection 7992.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": "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#8",
" └─TopN 1.00 root Column#10, offset:0, count:1",
" └─Projection 10000.00 root test.t.a, test.t.b, Column#8, and(eq(test.t.b, 1), Column#8)->Column#10",
" └─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 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 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 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 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]You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use [parser:8064]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]You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use [parser:8064]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]You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use [parser:8064]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_10 1.00 root Column#3, offset:0, count:1",
"└─StreamAgg_17 8000.00 root group by:test.t.a, funcs:count(1)->Column#3",
" └─Sort_22 10000.00 root test.t.a",
" └─TableReader_21 10000.00 root data:TableFullScan_20",
" └─TableFullScan_20 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_5 8000.00 root Column#3",
"└─StreamAgg_11 8000.00 root group by:test.t.a, funcs:count(1)->Column#3",
" └─Sort_16 10000.00 root test.t.a",
" └─TableReader_15 10000.00 root data:TableFullScan_14",
" └─TableFullScan_14 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_8 1.00 root Column#3",
"└─Limit_14 1.00 root offset:0, count:1",
" └─StreamAgg_27 1.00 root group by:test.t.a, funcs:count(1)->Column#3, funcs:firstrow(test.t.a)->test.t.a",
" └─Sort_32 1.25 root test.t.a",
" └─TableReader_31 1.25 root data:TableFullScan_30",
" └─TableFullScan_30 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_6 8000.00 root Column#3",
"└─StreamAgg_21 8000.00 root group by:test.t.a, funcs:count(1)->Column#3, funcs:firstrow(test.t.a)->test.t.a",
" └─Sort_17 10000.00 root test.t.a",
" └─TableReader_16 10000.00 root data:TableFullScan_15",
" └─TableFullScan_15 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_8 30000.00 root ",
"├─TableReader_10 10000.00 root data:TableFullScan_9",
"│ └─TableFullScan_9 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo",
"├─TableReader_12 10000.00 root data:TableFullScan_11",
"│ └─TableFullScan_11 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo",
"└─TableReader_14 10000.00 root data:TableFullScan_13",
" └─TableFullScan_13 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_7 20000.00 root ",
"├─IndexLookUp_10 10000.00 root ",
"│ ├─IndexFullScan_8(Build) 10000.00 cop[tikv] table:t, partition:p1, index:b(b) keep order:false, stats:pseudo",
"│ └─TableRowIDScan_9(Probe) 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo",
"└─TableReader_17 10000.00 root data:TableFullScan_16",
" └─TableFullScan_16 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_7 20000.00 root ",
"├─TableReader_11 10000.00 root data:TableFullScan_10",
"│ └─TableFullScan_10 10000.00 cop[tiflash] table:t, partition:p1 keep order:false, stats:pseudo",
"└─TableReader_15 10000.00 root data:TableFullScan_14",
" └─TableFullScan_14 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_8 30000.00 root ",
"├─IndexLookUp_11 10000.00 root ",
"│ ├─IndexFullScan_9(Build) 10000.00 cop[tikv] table:t, partition:p0, index:b(b) keep order:false, stats:pseudo",
"│ └─TableRowIDScan_10(Probe) 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo",
"├─IndexLookUp_17 10000.00 root ",
"│ ├─IndexFullScan_15(Build) 10000.00 cop[tikv] table:t, partition:p1, index:b(b) keep order:false, stats:pseudo",
"│ └─TableRowIDScan_16(Probe) 10000.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo",
"└─TableReader_24 10000.00 root data:TableFullScan_23",
" └─TableFullScan_23 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_8 30000.00 root ",
"├─TableReader_12 10000.00 root data:TableFullScan_11",
"│ └─TableFullScan_11 10000.00 cop[tiflash] table:t, partition:p0 keep order:false, stats:pseudo",
"├─TableReader_16 10000.00 root data:TableFullScan_15",
"│ └─TableFullScan_15 10000.00 cop[tiflash] table:t, partition:p1 keep order:false, stats:pseudo",
"└─TableReader_20 10000.00 root data:TableFullScan_19",
" └─TableFullScan_19 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_16 37500.00 root inner join, equal:[eq(test.t.a, test.t.a)]",
"├─PartitionUnion_31(Build) 30000.00 root ",
"│ ├─TableReader_35 10000.00 root data:TableFullScan_34",
"│ │ └─TableFullScan_34 10000.00 cop[tiflash] table:t2, partition:p0 keep order:false, stats:pseudo",
"│ ├─TableReader_39 10000.00 root data:TableFullScan_38",
"│ │ └─TableFullScan_38 10000.00 cop[tiflash] table:t2, partition:p1 keep order:false, stats:pseudo",
"│ └─TableReader_43 10000.00 root data:TableFullScan_42",
"│ └─TableFullScan_42 10000.00 cop[tiflash] table:t2, partition:p2 keep order:false, stats:pseudo",
"└─PartitionUnion_18(Probe) 30000.00 root ",
" ├─TableReader_22 10000.00 root data:TableFullScan_21",
" │ └─TableFullScan_21 10000.00 cop[tiflash] table:t1, partition:p0 keep order:false, stats:pseudo",
" ├─TableReader_26 10000.00 root data:TableFullScan_25",
" │ └─TableFullScan_25 10000.00 cop[tiflash] table:t1, partition:p1 keep order:false, stats:pseudo",
" └─TableReader_30 10000.00 root data:TableFullScan_29",
" └─TableFullScan_29 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_9 59.97 root ",
"├─IndexMerge_13 19.99 root ",
"│ ├─IndexRangeScan_10(Build) 10.00 cop[tikv] table:t, partition:p0, index:b(b) range:[1,1], keep order:false, stats:pseudo",
"│ ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, partition:p0, index:c(c) range:[\"8\",\"8\"], keep order:false, stats:pseudo",
"│ └─TableRowIDScan_12(Probe) 19.99 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo",
"├─TableReader_19 19.99 root data:Selection_18",
"│ └─Selection_18 19.99 cop[tiflash] or(eq(test.t.b, 1), eq(test.t.c, \"8\"))",
"│ └─TableFullScan_17 10000.00 cop[tiflash] table:t, partition:p1 keep order:false, stats:pseudo",
"└─TableReader_25 19.99 root data:Selection_24",
" └─Selection_24 19.99 cop[tiflash] or(eq(test.t.b, 1), eq(test.t.c, \"8\"))",
" └─TableFullScan_23 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_9 33.00 root ",
"├─IndexMerge_13 11.00 root ",
"│ ├─TableRangeScan_10(Build) 1.00 cop[tikv] table:t, partition:p0 range:[1,1], keep order:false, stats:pseudo",
"│ ├─IndexRangeScan_11(Build) 10.00 cop[tikv] table:t, partition:p0, index:b(b) range:[2,2], keep order:false, stats:pseudo",
"│ └─TableRowIDScan_12(Probe) 11.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo",
"├─IndexMerge_17 11.00 root ",
"│ ├─TableRangeScan_14(Build) 1.00 cop[tikv] table:t, partition:p1 range:[1,1], keep order:false, stats:pseudo",
"│ ├─IndexRangeScan_15(Build) 10.00 cop[tikv] table:t, partition:p1, index:b(b) range:[2,2], keep order:false, stats:pseudo",
"│ └─TableRowIDScan_16(Probe) 11.00 cop[tikv] table:t, partition:p1 keep order:false, stats:pseudo",
"└─TableReader_23 11.00 root data:Selection_22",
" └─Selection_22 11.00 cop[tiflash] or(eq(test.t.a, 1), eq(test.t.b, 2))",
" └─TableFullScan_21 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_7 20000.00 root ",
"├─IndexLookUp_10 10000.00 root ",
"│ ├─IndexFullScan_8(Build) 10000.00 cop[tikv] table:t, partition:p0, index:b(b) keep order:false, stats:pseudo",
"│ └─TableRowIDScan_9(Probe) 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo",
"└─TableReader_14 10000.00 root data:TableFullScan_13",
" └─TableFullScan_13 10000.00 cop[tiflash] table:t, partition:p1 keep order:false, stats:pseudo"
],
"Warn": null
},
{
"SQL": "select /*+ read_from_storage(tikv[t partition(p0)], tiflash[t partition(p1, p2)]) */ * from t",
"Plan": [
"PartitionUnion_8 30000.00 root ",
"├─TableReader_10 10000.00 root data:TableFullScan_9",
"│ └─TableFullScan_9 10000.00 cop[tikv] table:t, partition:p0 keep order:false, stats:pseudo",
"├─TableReader_12 10000.00 root data:TableFullScan_11",
"│ └─TableFullScan_11 10000.00 cop[tiflash] table:t, partition:p1 keep order:false, stats:pseudo",
"└─TableReader_14 10000.00 root data:TableFullScan_13",
" └─TableFullScan_13 10000.00 cop[tiflash] table:t, partition:p2 keep order:false, stats:pseudo"
],
"Warn": null
}
]
},
{
"Name": "TestAccessPathOnClusterIndex",
"Cases": [
{
"SQL": "select * from t1",
"Plan": [
"TableReader_5 3.00 root data:TableFullScan_4",
"└─TableFullScan_4 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_6 3.00 root data:TableRangeScan_5",
"└─TableRangeScan_5 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_6 0.67 root data:TableRangeScan_5",
"└─TableRangeScan_5 0.67 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_6 1.00 root index:IndexRangeScan_5",
"└─IndexRangeScan_5 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_6 1.00 root index:IndexRangeScan_5",
"└─IndexRangeScan_5 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_6 3.00 root ",
"├─IndexFullScan_4(Build) 3.00 cop[tikv] table:t1, index:c(c) keep order:false",
"└─TableRowIDScan_5(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_7 2.00 root ",
"├─IndexRangeScan_5(Build) 2.00 cop[tikv] table:t1, index:c(c) range:[2.2000000000,2.2000000000], [3.3000000000,3.3000000000], keep order:false",
"└─TableRowIDScan_6(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_12 1.00 root data:TableRangeScan_11",
"└─TableRangeScan_11 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_10 1.00 root offset:0, count:1",
"└─TableReader_20 1.00 root data:Limit_19",
" └─Limit_19 1.00 cop[tikv] offset:0, count:1",
" └─TableFullScan_18 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_8 3.00 root ",
"├─TableRangeScan_5(Build) 3.00 cop[tikv] table:t1 range:[1,+inf], keep order:false",
"├─IndexRangeScan_6(Build) 1.00 cop[tikv] table:t1, index:c(c) range:[2.2000000000,2.2000000000], keep order:false",
"└─TableRowIDScan_7(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_8 2.11 root ",
"├─TableRangeScan_5(Build) 1.00 cop[tikv] table:t1 range:[1 \"111\",1 \"111\"], keep order:false",
"├─IndexRangeScan_6(Build) 1.00 cop[tikv] table:t1, index:c(c) range:[3.3000000000,3.3000000000], keep order:false",
"└─TableRowIDScan_7(Probe) 2.11 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_12 3.00 root inner join, inner:TableReader_9, outer key:test.t.a, inner key:test.t.a, equal cond:eq(test.t.a, test.t.a)",
"├─TableReader_27(Build) 3.00 root data:TableFullScan_26",
"│ └─TableFullScan_26 3.00 cop[tikv] table:t1 keep order:false",
"└─TableReader_9(Probe) 1.00 root data:TableRangeScan_8",
" └─TableRangeScan_8 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_16 3.00 root inner join, inner:TableReader_11, outer key:test.t.a, inner key:test.t.a",
"├─TableReader_27(Build) 3.00 root data:TableFullScan_26",
"│ └─TableFullScan_26 3.00 cop[tikv] table:t1 keep order:false",
"└─TableReader_11(Probe) 1.00 root data:TableRangeScan_10",
" └─TableRangeScan_10 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_14 3.00 root inner join, inner:TableReader_9, outer key:test.t.a, inner key:test.t.a, equal cond:eq(test.t.a, test.t.a)",
"├─TableReader_27(Build) 3.00 root data:TableFullScan_26",
"│ └─TableFullScan_26 3.00 cop[tikv] table:t1 keep order:false",
"└─TableReader_9(Probe) 1.00 root data:TableRangeScan_8",
" └─TableRangeScan_8 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_12 3.00 root inner join, inner:TableReader_9, 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_27(Build) 3.00 root data:TableFullScan_26",
"│ └─TableFullScan_26 3.00 cop[tikv] table:t1 keep order:false",
"└─TableReader_9(Probe) 1.00 root data:TableRangeScan_8",
" └─TableRangeScan_8 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_12 3.00 root inner join, inner:IndexLookUp_11, outer key:test.t.c, inner key:test.t.c, equal cond:eq(test.t.c, test.t.c)",
"├─TableReader_36(Build) 3.00 root data:Selection_35",
"│ └─Selection_35 3.00 cop[tikv] not(isnull(test.t.c))",
"│ └─TableFullScan_34 3.00 cop[tikv] table:t1 keep order:false",
"└─IndexLookUp_11(Probe) 1.00 root ",
" ├─Selection_10(Build) 1.00 cop[tikv] not(isnull(test.t.c))",
" │ └─IndexRangeScan_8 1.00 cop[tikv] table:t2, index:c(c) range: decided by [eq(test.t.c, test.t.c)], keep order:false",
" └─TableRowIDScan_9(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_19 3.00 root left outer join, inner:Projection_17, outer key:Column#9, inner key:test.t.c",
"├─Projection_20(Build) 3.00 root cast(test.t.a, decimal(20,0) BINARY)->Column#9",
"│ └─TableReader_22 3.00 root data:TableFullScan_21",
"│ └─TableFullScan_21 3.00 cop[tikv] table:t1 keep order:false",
"└─Projection_17(Probe) 1.00 root test.t.a, test.t.c, test.t.d",
" └─IndexLookUp_16 1.00 root ",
" ├─IndexRangeScan_14(Build) 1.00 cop[tikv] table:t2, index:c(c) range: decided by [eq(test.t.c, Column#9)], keep order:true",
" └─TableRowIDScan_15(Probe) 1.00 cop[tikv] table:t2 keep order:false"
],
"Res": [
"<nil> <nil> <nil>",
"<nil> <nil> <nil>",
"<nil> <nil> <nil>"
]
}
]
},
{
"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": [
"Projection_4 3330.01 root test.pt.id, test.pt.c",
"└─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": [
"Projection_4 3340.00 root test.pt.id, test.pt.c",
"└─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"
]
}
]
}
]