Files
tidb/expression/testdata/partition_pruner_out.json

934 lines
44 KiB
JSON

[
{
"Name": "TestHashPartitionPruner",
"Cases": [
{
"SQL": "explain select * from t1 where id = 7 and a = 6",
"Result": [
"TableReader_7 0.00 root partition:p7 data:Selection_6",
"└─Selection_6 0.00 cop[tikv] eq(test_partition.t1.a, 6)",
" └─TableRangeScan_5 1.00 cop[tikv] table:t1 range:[7,7], keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t3 where id = 9 and a = 1",
"Result": [
"Point_Get_1 1.00 root table:t3, partition:p9, index:PRIMARY(id, a) "
]
},
{
"SQL": "explain select * from t2 where id = 9 and a = -110",
"Result": [
"IndexLookUp_7 1.00 root partition:p1 ",
"├─IndexRangeScan_5(Build) 1.00 cop[tikv] table:t2, index:PRIMARY(id, a) range:[9 -110,9 -110], keep order:false, stats:pseudo",
"└─TableRowIDScan_6(Probe) 1.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t1 where id = -17",
"Result": [
"TableReader_6 1.00 root partition:p7 data:TableRangeScan_5",
"└─TableRangeScan_5 1.00 cop[tikv] table:t1 range:[-17,-17], keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t1 join t2 on (t1.id = t2.id) where t1.id = 5 and t2.a = 7",
"Result": [
"HashJoin_8 1.00 root CARTESIAN inner join",
"├─IndexLookUp_14(Build) 1.00 root partition:p2 ",
"│ ├─IndexRangeScan_12(Build) 1.00 cop[tikv] table:t2, index:PRIMARY(id, a) range:[5 7,5 7], keep order:false, stats:pseudo",
"│ └─TableRowIDScan_13(Probe) 1.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
"└─TableReader_11(Probe) 1.00 root partition:p5 data:TableRangeScan_10",
" └─TableRangeScan_10 1.00 cop[tikv] table:t1 range:[5,5], keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t1 left join t2 on t1.id = 1 and t2.a = 2 where t2.id = 7",
"Result": [
"HashJoin_7 1.00 root CARTESIAN inner join",
"├─IndexLookUp_13(Build) 1.00 root partition:p9 ",
"│ ├─IndexRangeScan_11(Build) 1.00 cop[tikv] table:t2, index:PRIMARY(id, a) range:[7 2,7 2], keep order:false, stats:pseudo",
"│ └─TableRowIDScan_12(Probe) 1.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
"└─TableReader_10(Probe) 1.00 root partition:p1 data:TableRangeScan_9",
" └─TableRangeScan_9 1.00 cop[tikv] table:t1 range:[1,1], keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t2 join t1 on t1.id = t2.id and t2.a = t1.id and t2.id = 12",
"Result": [
"HashJoin_7 1.00 root CARTESIAN inner join",
"├─TableReader_13(Build) 1.00 root partition:p2 data:TableRangeScan_12",
"│ └─TableRangeScan_12 1.00 cop[tikv] table:t1 range:[12,12], keep order:false, stats:pseudo",
"└─IndexLookUp_11(Probe) 1.00 root partition:p4 ",
" ├─IndexRangeScan_9(Build) 1.00 cop[tikv] table:t2, index:PRIMARY(id, a) range:[12 12,12 12], keep order:false, stats:pseudo",
" └─TableRowIDScan_10(Probe) 1.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t1 left join t2 on true where t1.a = 1 and false",
"Result": [
"TableDual_8 0.00 root rows:0"
]
},
{
"SQL": "explain select * from t1 left join t2 on true where t1.a = 1 and null",
"Result": [
"TableDual_8 0.00 root rows:0"
]
},
{
"SQL": "explain select * from t1 left join t2 on true where t1.a = null",
"Result": [
"TableDual_8 0.00 root rows:0"
]
},
{
"SQL": "explain select * from t4 where d = '2019-10-07 10:40:00' and a = 1",
"Result": [
"IndexLookUp_7 1.00 root partition:p9 ",
"├─IndexRangeScan_5(Build) 1.00 cop[tikv] table:t4, index:PRIMARY(d, a) range:[2019-10-07 10:40:00 1,2019-10-07 10:40:00 1], keep order:false, stats:pseudo",
"└─TableRowIDScan_6(Probe) 1.00 cop[tikv] table:t4 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t5 where d = '2019-10-07'",
"Result": [
"IndexLookUp_10 10.00 root partition:p0 ",
"├─IndexRangeScan_8(Build) 10.00 cop[tikv] table:t5, index:PRIMARY(d, a) range:[2019-10-07,2019-10-07], keep order:false, stats:pseudo",
"└─TableRowIDScan_9(Probe) 10.00 cop[tikv] table:t5 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t6 where a is null",
"Result": [
"TableReader_7 10.00 root partition:p0 data:Selection_6",
"└─Selection_6 10.00 cop[tikv] isnull(test_partition.t6.a)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t6 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t6 where b is null",
"Result": [
"TableReader_7 10.00 root partition:all data:Selection_6",
"└─Selection_6 10.00 cop[tikv] isnull(test_partition.t6.b)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t6 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t6 where a = 7 or a = 6",
"Result": [
"TableReader_7 20.00 root partition:p0,p1 data:Selection_6",
"└─Selection_6 20.00 cop[tikv] or(eq(test_partition.t6.a, 7), eq(test_partition.t6.a, 6))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t6 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t6 where a in (6, 7)",
"Result": [
"TableReader_7 20.00 root partition:p0,p1 data:Selection_6",
"└─Selection_6 20.00 cop[tikv] in(test_partition.t6.a, 6, 7)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t6 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t5 where d is null",
"Result": [
"TableDual_6 0.00 root rows:0"
]
},
{
"SQL": "explain select * from t7 where b = -3 and a is null",
"Result": [
"TableReader_7 0.01 root partition:p0 data:Selection_6",
"└─Selection_6 0.01 cop[tikv] eq(test_partition.t7.b, -3), isnull(test_partition.t7.a)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t7 where (a, b) in ((3, 4), (5, 6))",
"Result": [
"TableReader_7 0.02 root partition:p1,p7 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] or(and(eq(test_partition.t7.a, 3), eq(test_partition.t7.b, 4)), and(eq(test_partition.t7.a, 5), eq(test_partition.t7.b, 6)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t7 where (a = 1 and b = 2) or (a = 3 and b = 4)",
"Result": [
"TableReader_7 0.02 root partition:p3,p7 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] or(and(eq(test_partition.t7.a, 1), eq(test_partition.t7.b, 2)), and(eq(test_partition.t7.a, 3), eq(test_partition.t7.b, 4)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t7 where (a = 1 and b = 2) or (a = 1 and b = 2)",
"Result": [
"TableReader_7 0.02 root partition:p3 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] or(and(eq(test_partition.t7.a, 1), eq(test_partition.t7.b, 2)), and(eq(test_partition.t7.a, 1), eq(test_partition.t7.b, 2)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t7 partition(p0) where (a = 1 and b = 2) or (a = 3 and b = 4)",
"Result": [
"TableReader_7 0.02 root partition:dual data:Selection_6",
"└─Selection_6 0.02 cop[tikv] or(and(eq(test_partition.t7.a, 1), eq(test_partition.t7.b, 2)), and(eq(test_partition.t7.a, 3), eq(test_partition.t7.b, 4)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo"
]
}
]
},
{
"Name": "TestListPartitionPruner",
"Cases": [
{
"SQL": "select * from t1 where id = 6 and a = 6",
"Result": [
"6 6 6"
],
"Plan": [
"TableReader_7 0.01 root partition:p1 data:Selection_6",
"└─Selection_6 0.01 cop[tikv] eq(test_partition.t1.a, 6), eq(test_partition.t1.id, 6)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where id = 6 and a = 6 and b = 6",
"Result": [
"6 6 6"
],
"Plan": [
"TableReader_7 0.00 root partition:p1 data:Selection_6",
"└─Selection_6 0.00 cop[tikv] eq(test_partition.t2.a, 6), eq(test_partition.t2.b, 6), eq(test_partition.t2.id, 6)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where id = 6 and a = 6",
"Result": [
"6 6 6"
],
"Plan": [
"TableReader_7 0.01 root partition:p1 data:Selection_6",
"└─Selection_6 0.01 cop[tikv] eq(test_partition.t3.a, 6), eq(test_partition.t3.id, 6)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where id = 6 and (a = 6 or a is null)",
"Result": [
"6 6 6"
],
"Plan": [
"TableReader_7 0.02 root partition:p1 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] eq(test_partition.t1.id, 6), or(eq(test_partition.t1.a, 6), isnull(test_partition.t1.a))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where id = 6 and (a = 6 and b = 6 ) or ( a is null and b = 6 )",
"Result": [
"6 6 6"
],
"Plan": [
"TableReader_7 0.01 root partition:p1 data:Selection_6",
"└─Selection_6 0.01 cop[tikv] or(and(eq(test_partition.t2.id, 6), and(eq(test_partition.t2.a, 6), eq(test_partition.t2.b, 6))), and(isnull(test_partition.t2.a), eq(test_partition.t2.b, 6)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where id = 6 and (a = 6 or a is null)",
"Result": [
"6 6 6"
],
"Plan": [
"TableReader_7 0.02 root partition:p1 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] eq(test_partition.t3.id, 6), or(eq(test_partition.t3.a, 6), isnull(test_partition.t3.a))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where id = 6 and (a = 1 or a is null)",
"Result": null,
"Plan": [
"TableReader_7 0.02 root partition:p0,p1 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] eq(test_partition.t1.id, 6), or(eq(test_partition.t1.a, 1), isnull(test_partition.t1.a))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where id = 6 and (a = 6 and b = 6) or ( a is null and b = 6)",
"Result": [
"6 6 6"
],
"Plan": [
"TableReader_7 0.01 root partition:p1 data:Selection_6",
"└─Selection_6 0.01 cop[tikv] or(and(eq(test_partition.t2.id, 6), and(eq(test_partition.t2.a, 6), eq(test_partition.t2.b, 6))), and(isnull(test_partition.t2.a), eq(test_partition.t2.b, 6)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where id = 6 and (a = 1 or a is null)",
"Result": null,
"Plan": [
"TableReader_7 0.02 root partition:p0,p1 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] eq(test_partition.t3.id, 6), or(eq(test_partition.t3.a, 1), isnull(test_partition.t3.a))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where (id = 1 and a = 1) or a is null",
"Result": [
"1 1 1",
"<nil> <nil> <nil>"
],
"Plan": [
"TableReader_7 10.01 root partition:p0,p1 data:Selection_6",
"└─Selection_6 10.01 cop[tikv] or(and(eq(test_partition.t1.id, 1), eq(test_partition.t1.a, 1)), isnull(test_partition.t1.a))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where (id = 1 and a = 1 and b = 1) or (a is null and b is null)",
"Result": [
"1 1 1",
"<nil> <nil> <nil>"
],
"Plan": [
"TableReader_7 0.01 root partition:p0,p1 data:Selection_6",
"└─Selection_6 0.01 cop[tikv] or(and(and(eq(test_partition.t2.id, 1), eq(test_partition.t2.a, 1)), eq(test_partition.t2.b, 1)), and(isnull(test_partition.t2.a), isnull(test_partition.t2.b)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where (id = 1 and a = 1) or a is null",
"Result": [
"1 1 1",
"<nil> <nil> <nil>"
],
"Plan": [
"TableReader_7 10.01 root partition:p0,p1 data:Selection_6",
"└─Selection_6 10.01 cop[tikv] or(and(eq(test_partition.t3.id, 1), eq(test_partition.t3.a, 1)), isnull(test_partition.t3.a))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where (id = 1 and a = 1) or (a = 1 and id = 1)",
"Result": [
"1 1 1"
],
"Plan": [
"TableReader_7 0.02 root partition:p0 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] or(and(eq(test_partition.t1.id, 1), eq(test_partition.t1.a, 1)), and(eq(test_partition.t1.a, 1), eq(test_partition.t1.id, 1)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where (id = 1 and a = 1 and b = 1) or (a = 1 and id = 1 and b=1)",
"Result": [
"1 1 1"
],
"Plan": [
"TableReader_7 0.00 root partition:p0 data:Selection_6",
"└─Selection_6 0.00 cop[tikv] or(and(and(eq(test_partition.t2.id, 1), eq(test_partition.t2.a, 1)), eq(test_partition.t2.b, 1)), and(and(eq(test_partition.t2.a, 1), eq(test_partition.t2.id, 1)), eq(test_partition.t2.b, 1)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where (id = 1 and a = 1) or (a = 1 and id = 1)",
"Result": [
"1 1 1"
],
"Plan": [
"TableReader_7 0.02 root partition:p0 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] or(and(eq(test_partition.t3.id, 1), eq(test_partition.t3.a, 1)), and(eq(test_partition.t3.a, 1), eq(test_partition.t3.id, 1)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a is null",
"Result": [
"<nil> <nil> <nil>"
],
"Plan": [
"TableReader_7 10.00 root partition:p1 data:Selection_6",
"└─Selection_6 10.00 cop[tikv] isnull(test_partition.t1.a)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where a is null and b is null",
"Result": [
"<nil> <nil> <nil>"
],
"Plan": [
"TableReader_7 0.01 root partition:p1 data:Selection_6",
"└─Selection_6 0.01 cop[tikv] isnull(test_partition.t2.a), isnull(test_partition.t2.b)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where a is null",
"Result": [
"<nil> <nil> <nil>"
],
"Plan": [
"TableReader_7 10.00 root partition:p1 data:Selection_6",
"└─Selection_6 10.00 cop[tikv] isnull(test_partition.t3.a)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a=id and id >10",
"Result": null,
"Plan": [
"TableReader_7 2666.67 root partition:all data:Selection_6",
"└─Selection_6 2666.67 cop[tikv] eq(test_partition.t1.a, test_partition.t1.id), gt(test_partition.t1.id, 10)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where a=id and id >10",
"Result": null,
"Plan": [
"TableReader_7 2666.67 root partition:all data:Selection_6",
"└─Selection_6 2666.67 cop[tikv] eq(test_partition.t2.a, test_partition.t2.id), gt(test_partition.t2.id, 10)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where a=id and id >10",
"Result": null,
"Plan": [
"TableReader_7 2666.67 root partition:all data:Selection_6",
"└─Selection_6 2666.67 cop[tikv] eq(test_partition.t3.a, test_partition.t3.id), gt(test_partition.t3.id, 10)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a=id and id >10 or a is null",
"Result": [
"<nil> <nil> <nil>"
],
"Plan": [
"TableReader_7 2674.00 root partition:all data:Selection_6",
"└─Selection_6 2674.00 cop[tikv] or(and(eq(test_partition.t1.a, test_partition.t1.id), gt(test_partition.t1.id, 10)), isnull(test_partition.t1.a))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where a=id and id >10 or a is null",
"Result": [
"<nil> <nil> <nil>"
],
"Plan": [
"TableReader_7 2674.00 root partition:all data:Selection_6",
"└─Selection_6 2674.00 cop[tikv] or(and(eq(test_partition.t2.a, test_partition.t2.id), gt(test_partition.t2.id, 10)), isnull(test_partition.t2.a))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where a=id and id >10 or a is null",
"Result": [
"<nil> <nil> <nil>"
],
"Plan": [
"TableReader_7 2674.00 root partition:all data:Selection_6",
"└─Selection_6 2674.00 cop[tikv] or(and(eq(test_partition.t3.a, test_partition.t3.id), gt(test_partition.t3.id, 10)), isnull(test_partition.t3.a))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a in (1,2) or a=4",
"Result": [
"1 1 1",
"2 2 2",
"4 4 4"
],
"Plan": [
"TableReader_7 30.00 root partition:p0 data:Selection_6",
"└─Selection_6 30.00 cop[tikv] or(in(test_partition.t1.a, 1, 2), eq(test_partition.t1.a, 4))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where a in (1,2) or a=4",
"Result": [
"1 1 1",
"2 2 2",
"4 4 4"
],
"Plan": [
"TableReader_7 30.00 root partition:all data:Selection_6",
"└─Selection_6 30.00 cop[tikv] or(in(test_partition.t2.a, 1, 2), eq(test_partition.t2.a, 4))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where a in (1,2) or a=4",
"Result": [
"1 1 1",
"2 2 2",
"4 4 4"
],
"Plan": [
"TableReader_7 30.00 root partition:p0 data:Selection_6",
"└─Selection_6 30.00 cop[tikv] or(in(test_partition.t3.a, 1, 2), eq(test_partition.t3.a, 4))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a in (1,2) or a=6",
"Result": [
"1 1 1",
"2 2 2",
"6 6 6"
],
"Plan": [
"TableReader_7 30.00 root partition:p0,p1 data:Selection_6",
"└─Selection_6 30.00 cop[tikv] or(in(test_partition.t1.a, 1, 2), eq(test_partition.t1.a, 6))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where (a in (1,2) or a=7) and b = 2",
"Result": [
"2 2 2"
],
"Plan": [
"TableReader_7 0.03 root partition:p0,p1 data:Selection_6",
"└─Selection_6 0.03 cop[tikv] eq(test_partition.t2.b, 2), or(in(test_partition.t2.a, 1, 2), eq(test_partition.t2.a, 7))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where a in (1,2) or a=8",
"Result": [
"1 1 1",
"2 2 2",
"8 8 8"
],
"Plan": [
"TableReader_7 30.00 root partition:p0,p1 data:Selection_6",
"└─Selection_6 30.00 cop[tikv] or(in(test_partition.t3.a, 1, 2), eq(test_partition.t3.a, 8))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where id = 1 or b = 1",
"Result": [
"1 1 1"
],
"Plan": [
"TableReader_7 19.99 root partition:all data:Selection_6",
"└─Selection_6 19.99 cop[tikv] or(eq(test_partition.t1.id, 1), eq(test_partition.t1.b, 1))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where id = 1 or b = 1",
"Result": [
"1 1 1"
],
"Plan": [
"TableReader_7 19.99 root partition:all data:Selection_6",
"└─Selection_6 19.99 cop[tikv] or(eq(test_partition.t2.id, 1), eq(test_partition.t2.b, 1))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where id = 1 or b = 1",
"Result": [
"1 1 1"
],
"Plan": [
"TableReader_7 19.99 root partition:all data:Selection_6",
"└─Selection_6 19.99 cop[tikv] or(eq(test_partition.t3.id, 1), eq(test_partition.t3.b, 1))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a = 100",
"Result": null,
"Plan": [
"TableReader_7 10.00 root partition:dual data:Selection_6",
"└─Selection_6 10.00 cop[tikv] eq(test_partition.t1.a, 100)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 where a = 100 and b = 100",
"Result": null,
"Plan": [
"TableReader_7 0.01 root partition:dual data:Selection_6",
"└─Selection_6 0.01 cop[tikv] eq(test_partition.t2.a, 100), eq(test_partition.t2.b, 100)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 where a = 100",
"Result": null,
"Plan": [
"TableReader_7 10.00 root partition:dual data:Selection_6",
"└─Selection_6 10.00 cop[tikv] eq(test_partition.t3.a, 100)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 partition(p0) where a in (1,3,5,7)",
"Result": [
"1 1 1",
"3 3 3",
"5 5 5"
],
"Plan": [
"TableReader_7 40.00 root partition:p0 data:Selection_6",
"└─Selection_6 40.00 cop[tikv] in(test_partition.t1.a, 1, 3, 5, 7)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 partition(p0) where b in (1,3,5,7)",
"Result": [
"1 1 1",
"3 3 3",
"5 5 5"
],
"Plan": [
"TableReader_7 40.00 root partition:p0 data:Selection_6",
"└─Selection_6 40.00 cop[tikv] in(test_partition.t2.b, 1, 3, 5, 7)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 partition(p1) where a in (1,3,5,7)",
"Result": [
"7 7 7"
],
"Plan": [
"TableReader_7 40.00 root partition:p1 data:Selection_6",
"└─Selection_6 40.00 cop[tikv] in(test_partition.t1.a, 1, 3, 5, 7)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t2 partition(p1) where a in (1,3,5,7)",
"Result": [
"7 7 7"
],
"Plan": [
"TableReader_7 40.00 root partition:p1 data:Selection_6",
"└─Selection_6 40.00 cop[tikv] in(test_partition.t2.a, 1, 3, 5, 7)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 join t2 on t1.id = t2.id where (t1.a=1 or t1.a = 3) and (t2.a = 6 and t2.b = 6)",
"Result": null,
"Plan": [
"Projection_7 0.01 root test_partition.t1.id, test_partition.t1.a, test_partition.t1.b, test_partition.t2.a, test_partition.t2.id, test_partition.t2.b",
"└─HashJoin_9 0.01 root inner join, equal:[eq(test_partition.t2.id, test_partition.t1.id)]",
" ├─TableReader_12(Build) 0.01 root partition:p1 data:Selection_11",
" │ └─Selection_11 0.01 cop[tikv] eq(test_partition.t2.a, 6), eq(test_partition.t2.b, 6), not(isnull(test_partition.t2.id))",
" │ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
" └─TableReader_15(Probe) 19.98 root partition:p0 data:Selection_14",
" └─Selection_14 19.98 cop[tikv] not(isnull(test_partition.t1.id)), or(eq(test_partition.t1.a, 1), eq(test_partition.t1.a, 3))",
" └─TableFullScan_13 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 left join t3 on t1.id = t3.id where (t1.a=1 or t1.a = 3) and t3.a in (6,7,8)",
"Result": null,
"Plan": [
"HashJoin_8 24.98 root inner join, equal:[eq(test_partition.t1.id, test_partition.t3.id)]",
"├─TableReader_11(Build) 19.98 root partition:p0 data:Selection_10",
"│ └─Selection_10 19.98 cop[tikv] not(isnull(test_partition.t1.id)), or(eq(test_partition.t1.a, 1), eq(test_partition.t1.a, 3))",
"│ └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo",
"└─TableReader_14(Probe) 29.97 root partition:p1 data:Selection_13",
" └─Selection_13 29.97 cop[tikv] in(test_partition.t3.a, 6, 7, 8), not(isnull(test_partition.t3.id))",
" └─TableFullScan_12 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t3 right join t2 on t3.id = t2.id where (t3.a=1 or t3.a = 3) and t2.a in (6,7,8) and t2.b = 6",
"Result": null,
"Plan": [
"HashJoin_7 0.04 root inner join, equal:[eq(test_partition.t3.id, test_partition.t2.id)]",
"├─TableReader_14(Build) 0.03 root partition:p1 data:Selection_13",
"│ └─Selection_13 0.03 cop[tikv] eq(test_partition.t2.b, 6), in(test_partition.t2.a, 6, 7, 8), not(isnull(test_partition.t2.id))",
"│ └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
"└─TableReader_11(Probe) 19.98 root partition:p0 data:Selection_10",
" └─Selection_10 19.98 cop[tikv] not(isnull(test_partition.t3.id)), or(eq(test_partition.t3.a, 1), eq(test_partition.t3.a, 3))",
" └─TableFullScan_9 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 join t2 on true where t1.a=5 and t2.a in (6,7,8) and t1.a-t2.a=1 and t2.b = 6",
"Result": null,
"Plan": [
"Projection_7 80.00 root test_partition.t1.id, test_partition.t1.a, test_partition.t1.b, test_partition.t2.a, test_partition.t2.id, test_partition.t2.b",
"└─HashJoin_9 80.00 root CARTESIAN inner join",
" ├─TableReader_12(Build) 8.00 root partition:p1 data:Selection_11",
" │ └─Selection_11 8.00 cop[tikv] 1, eq(minus(5, test_partition.t2.a), 1), eq(test_partition.t2.b, 6), in(test_partition.t2.a, 6, 7, 8)",
" │ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
" └─TableReader_15(Probe) 10.00 root partition:p0 data:Selection_14",
" └─Selection_14 10.00 cop[tikv] 1, eq(test_partition.t1.a, 5)",
" └─TableFullScan_13 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a = 6 union select * from t1 where a = 1 order by a",
"Result": [
"1 1 1",
"6 6 6"
],
"Plan": [
"Sort_12 16.00 root Column#10",
"└─HashAgg_16 16.00 root group by:Column#10, Column#11, Column#9, funcs:firstrow(Column#9)->Column#9, funcs:firstrow(Column#10)->Column#10, funcs:firstrow(Column#11)->Column#11",
" └─Union_17 20.00 root ",
" ├─TableReader_21 10.00 root partition:p1 data:Selection_20",
" │ └─Selection_20 10.00 cop[tikv] eq(test_partition.t1.a, 6)",
" │ └─TableFullScan_19 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo",
" └─TableReader_25 10.00 root partition:p0 data:Selection_24",
" └─Selection_24 10.00 cop[tikv] eq(test_partition.t1.a, 1)",
" └─TableFullScan_23 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t4 join t5 on t4.id = t5.id where (t4.a=1 or t4.a = 3) and (t5.a = 1 or t5.a = 6) and t5.b in (1,6)",
"Result": [
"1 1 1 1 1 1"
],
"Plan": [
"HashJoin_9 2.50 root inner join, equal:[eq(test_partition.t4.id, test_partition.t5.id)]",
"├─TableReader_12(Build) 2.00 root partition:p0 data:Selection_11",
"│ └─Selection_11 2.00 cop[tikv] not(isnull(test_partition.t4.id))",
"│ └─TableRangeScan_10 2.00 cop[tikv] table:t4 range:[1,1], [3,3], keep order:false, stats:pseudo",
"└─IndexLookUp_16(Probe) 4.00 root partition:p0,p1 ",
" ├─IndexRangeScan_13(Build) 4.00 cop[tikv] table:t5, index:a(a, b) range:[1 1,1 1], [1 6,1 6], [6 1,6 1], [6 6,6 6], keep order:false, stats:pseudo",
" └─Selection_15(Probe) 4.00 cop[tikv] not(isnull(test_partition.t5.id))",
" └─TableRowIDScan_14 4.00 cop[tikv] table:t5 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t4 t1 join t4 t2 on t1.id = t2.id where t1.a in (1, 4) and t2.a in (1,3,9,100)",
"Result": [
"1 1 1 1 1 1"
],
"Plan": [
"HashJoin_9 2.50 root inner join, equal:[eq(test_partition.t4.id, test_partition.t4.id)]",
"├─TableReader_12(Build) 2.00 root partition:p0 data:Selection_11",
"│ └─Selection_11 2.00 cop[tikv] not(isnull(test_partition.t4.id))",
"│ └─TableRangeScan_10 2.00 cop[tikv] table:t1 range:[1,1], [4,4], keep order:false, stats:pseudo",
"└─TableReader_15(Probe) 4.00 root partition:p0,p1 data:Selection_14",
" └─Selection_14 4.00 cop[tikv] not(isnull(test_partition.t4.id))",
" └─TableRangeScan_13 4.00 cop[tikv] table:t2 range:[1,1], [3,3], [9,9], [100,100], keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t6 t1 join t6 t2 on t1.id = t2.id where t1.a in (1, 4) and t2.a in (1,3,9,100)",
"Result": [
"1 1 1 1 1 1"
],
"Plan": [
"HashJoin_9 24.97 root inner join, equal:[eq(test_partition.t6.id, test_partition.t6.id)]",
"├─IndexLookUp_16(Build) 19.98 root partition:p0 ",
"│ ├─IndexRangeScan_13(Build) 20.00 cop[tikv] table:t1, index:a(a, b) range:[1,1], [4,4], keep order:false, stats:pseudo",
"│ └─Selection_15(Probe) 19.98 cop[tikv] not(isnull(test_partition.t6.id))",
"│ └─TableRowIDScan_14 20.00 cop[tikv] table:t1 keep order:false, stats:pseudo",
"└─IndexLookUp_23(Probe) 39.96 root partition:p0,p1 ",
" ├─IndexRangeScan_20(Build) 40.00 cop[tikv] table:t2, index:a(a, b) range:[1,1], [3,3], [9,9], [100,100], keep order:false, stats:pseudo",
" └─Selection_22(Probe) 39.96 cop[tikv] not(isnull(test_partition.t6.id))",
" └─TableRowIDScan_21 40.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
]
},
{
"SQL": "select count(*) from t6 join t5 on t6.b = t5.b where t6.a in (1,2) and t5.a in (1,6) and t5.b in (1,6)",
"Result": [
"1"
],
"Plan": [
"StreamAgg_13 1.00 root funcs:count(1)->Column#9",
"└─HashJoin_46 4.00 root inner join, equal:[eq(test_partition.t6.b, test_partition.t5.b)]",
" ├─IndexReader_33(Build) 4.00 root partition:p0,p1 index:Selection_32",
" │ └─Selection_32 4.00 cop[tikv] not(isnull(test_partition.t5.b))",
" │ └─IndexRangeScan_31 4.00 cop[tikv] table:t5, index:a(a, b) range:[1 1,1 1], [1 6,1 6], [6 1,6 1], [6 6,6 6], keep order:false, stats:pseudo",
" └─IndexReader_30(Probe) 4.00 root partition:p0 index:Selection_29",
" └─Selection_29 4.00 cop[tikv] not(isnull(test_partition.t6.b))",
" └─IndexRangeScan_28 4.00 cop[tikv] table:t6, index:a(a, b) range:[1 1,1 1], [1 6,1 6], [2 1,2 1], [2 6,2 6], keep order:false, stats:pseudo"
]
},
{
"SQL": "select /*+ INL_JOIN(t6,t5) */ count(*) from t6 join t5 on t6.b = t5.b where t6.a in (1,2) and t5.a in (1,6) and t5.b in (1,6)",
"Result": [
"1"
],
"Plan": [
"StreamAgg_12 1.00 root funcs:count(1)->Column#9",
"└─IndexJoin_34 4.00 root inner join, inner:IndexReader_33, outer key:test_partition.t6.b, inner key:test_partition.t5.b, equal cond:eq(test_partition.t6.b, test_partition.t5.b)",
" ├─IndexReader_27(Build) 4.00 root partition:p0 index:Selection_26",
" │ └─Selection_26 4.00 cop[tikv] not(isnull(test_partition.t6.b))",
" │ └─IndexRangeScan_25 4.00 cop[tikv] table:t6, index:a(a, b) range:[1 1,1 1], [1 6,1 6], [2 1,2 1], [2 6,2 6], keep order:false, stats:pseudo",
" └─IndexReader_33(Probe) 1.25 root partition:p0,p1 index:Selection_32",
" └─Selection_32 1.25 cop[tikv] in(test_partition.t5.b, 1, 6), not(isnull(test_partition.t5.b))",
" └─IndexRangeScan_31 625.00 cop[tikv] table:t5, index:a(a, b) range: decided by [eq(test_partition.t5.b, test_partition.t6.b) in(test_partition.t5.a, 1, 6)], keep order:false, stats:pseudo"
]
},
{
"SQL": "select /*+ INL_HASH_JOIN(t5,t6) */ count(*) from t6 join t5 on t6.b = t5.b where t6.a in (1,2) and t5.a in (1,6) and t5.b in (1,6)",
"Result": [
"1"
],
"Plan": [
"StreamAgg_12 1.00 root funcs:count(1)->Column#9",
"└─IndexHashJoin_36 4.00 root inner join, inner:IndexReader_33, outer key:test_partition.t6.b, inner key:test_partition.t5.b, equal cond:eq(test_partition.t6.b, test_partition.t5.b)",
" ├─IndexReader_27(Build) 4.00 root partition:p0 index:Selection_26",
" │ └─Selection_26 4.00 cop[tikv] not(isnull(test_partition.t6.b))",
" │ └─IndexRangeScan_25 4.00 cop[tikv] table:t6, index:a(a, b) range:[1 1,1 1], [1 6,1 6], [2 1,2 1], [2 6,2 6], keep order:false, stats:pseudo",
" └─IndexReader_33(Probe) 1.25 root partition:p0,p1 index:Selection_32",
" └─Selection_32 1.25 cop[tikv] in(test_partition.t5.b, 1, 6), not(isnull(test_partition.t5.b))",
" └─IndexRangeScan_31 625.00 cop[tikv] table:t5, index:a(a, b) range: decided by [eq(test_partition.t5.b, test_partition.t6.b) in(test_partition.t5.a, 1, 6)], keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t7 where a is null or a > 0 order by a;",
"Result": [
"<nil>",
"1",
"2"
],
"Plan": [
"Sort_5 3343.33 root test_partition.t7.a",
"└─TableReader_10 3343.33 root partition:all data:Selection_9",
" └─Selection_9 3343.33 cop[tikv] or(isnull(test_partition.t7.a), gt(test_partition.t7.a, 0))",
" └─TableFullScan_8 10000.00 cop[tikv] table:t7 keep order:false, stats:pseudo"
]
}
]
},
{
"Name": "TestListColumnsPartitionPruner",
"Cases": [
{
"SQL": "select * from t1 where a = 1 or b = 2",
"Result": [
"1 1 1",
"2 2 2"
],
"Plan": [
"TableReader_7 19.99 root partition:all data:Selection_6",
"└─Selection_6 19.99 cop[tikv] or(eq(test_partition.t1.a, 1), eq(test_partition.t1.b, 2))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a = 1 and b = 2",
"Result": null,
"Plan": [
"TableReader_7 0.01 root partition:dual data:Selection_6",
"└─Selection_6 0.01 cop[tikv] eq(test_partition.t1.a, 1), eq(test_partition.t1.b, 2)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a = 1 and b = 1",
"Result": [
"1 1 1"
],
"Plan": [
"TableReader_7 0.01 root partition:p0 data:Selection_6",
"└─Selection_6 0.01 cop[tikv] eq(test_partition.t1.a, 1), eq(test_partition.t1.b, 1)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a in (1,2,3) or b in (4,5,6)",
"Result": [
"1 1 1",
"2 2 2",
"3 3 3",
"4 4 4",
"5 5 5",
"6 6 6"
],
"Plan": [
"TableReader_7 59.91 root partition:all data:Selection_6",
"└─Selection_6 59.91 cop[tikv] or(in(test_partition.t1.a, 1, 2, 3), in(test_partition.t1.b, 4, 5, 6))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a in (1,2,3) and b in (4,5,6)",
"Result": null,
"Plan": [
"TableReader_7 0.09 root partition:dual data:Selection_6",
"└─Selection_6 0.09 cop[tikv] in(test_partition.t1.a, 1, 2, 3), in(test_partition.t1.b, 4, 5, 6)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a in (1,2,3) and b in (3,4,6)",
"Result": [
"3 3 3"
],
"Plan": [
"TableReader_7 0.09 root partition:p0 data:Selection_6",
"└─Selection_6 0.09 cop[tikv] in(test_partition.t1.a, 1, 2, 3), in(test_partition.t1.b, 3, 4, 6)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where ( a=1 and b=1) or (a=6 and b=6)",
"Result": [
"1 1 1",
"6 6 6"
],
"Plan": [
"TableReader_7 0.02 root partition:p0,p1 data:Selection_6",
"└─Selection_6 0.02 cop[tikv] or(and(eq(test_partition.t1.a, 1), eq(test_partition.t1.b, 1)), and(eq(test_partition.t1.a, 6), eq(test_partition.t1.b, 6)))",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 where a = 100 and b = 100",
"Result": null,
"Plan": [
"TableReader_7 0.01 root partition:dual data:Selection_6",
"└─Selection_6 0.01 cop[tikv] eq(test_partition.t1.a, 100), eq(test_partition.t1.b, 100)",
" └─TableFullScan_5 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 join t2 on t1.id = t2.id where (t1.a=1 or t1.a = 3 and t1.b in (3,5)) and t2.a in (6,7,8) and t2.b=7 and t2.id=7",
"Result": null,
"Plan": [
"Projection_7 0.00 root test_partition.t1.id, test_partition.t1.a, test_partition.t1.b, test_partition.t2.id, test_partition.t2.a, test_partition.t2.b",
"└─HashJoin_9 0.00 root CARTESIAN inner join",
" ├─TableReader_12(Build) 0.00 root partition:p1 data:Selection_11",
" │ └─Selection_11 0.00 cop[tikv] eq(test_partition.t2.b, 7), eq(test_partition.t2.id, 7), in(test_partition.t2.a, 6, 7, 8)",
" │ └─TableFullScan_10 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
" └─TableReader_15(Probe) 0.01 root partition:all data:Selection_14",
" └─Selection_14 0.01 cop[tikv] eq(test_partition.t1.id, 7), or(eq(test_partition.t1.a, 1), and(eq(test_partition.t1.a, 3), in(test_partition.t1.b, 3, 5)))",
" └─TableFullScan_13 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
},
{
"SQL": "select * from t1 left join t2 on true where (t1.a=1 or t1.a = 3 and t1.b in (3,5)) and t2.a in (6,7,8) and t2.b=7 and t2.id = 7",
"Result": [
"1 1 1 7 7 7",
"3 3 3 7 7 7"
],
"Plan": [
"HashJoin_7 80.16 root CARTESIAN inner join",
"├─TableReader_14(Build) 8.00 root partition:p1 data:Selection_13",
"│ └─Selection_13 8.00 cop[tikv] 1, eq(test_partition.t2.b, 7), eq(test_partition.t2.id, 7), in(test_partition.t2.a, 6, 7, 8)",
"│ └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
"└─TableReader_11(Probe) 10.02 root partition:all data:Selection_10",
" └─Selection_10 10.02 cop[tikv] 1, or(eq(test_partition.t1.a, 1), and(eq(test_partition.t1.a, 3), in(test_partition.t1.b, 3, 5)))",
" └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
]
}
]
}
]