github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/dbs/cmd/benchdb/explaintest/r/explain_easy.result (about) 1 use test; 2 drop causet if exists t1, t2, t3, t4; 3 create causet t1 (c1 int primary key, c2 int, c3 int, index c2 (c2)); 4 create causet t2 (c1 int unique, c2 int); 5 insert into t2 values(1, 0), (2, 1); 6 create causet t3 (a bigint, b bigint, c bigint, d bigint); 7 create causet t4 (a int, b int, c int, index idx(a, b), primary key(a)); 8 create index expr_idx on t4((a+b+1)); 9 set @@stochastik.milevadb_opt_agg_push_down = 1; 10 set @@stochastik.milevadb_opt_insubq_to_join_and_agg=1; 11 set @@stochastik.milevadb_hashagg_partial_concurrency = 1; 12 set @@stochastik.milevadb_hashagg_final_concurrency = 1; 13 set @@stochastik.milevadb_window_concurrency = 1; 14 explain select * from t3 where exists (select s.a from t3 s having sum(s.a) = t3.a ); 15 id estRows task access object operator info 16 HashJoin_12 8000.00 root semi join, equal:[eq(DeferredCauset#13, DeferredCauset#11)] 17 ├─StreamAgg_27(Build) 1.00 root funcs:sum(DeferredCauset#16)->DeferredCauset#11 18 │ └─TableReader_28 1.00 root data:StreamAgg_19 19 │ └─StreamAgg_19 1.00 cop[einsteindb] funcs:sum(test.t3.a)->DeferredCauset#16 20 │ └─TableFullScan_26 10000.00 cop[einsteindb] causet:s keep order:false, stats:pseudo 21 └─Projection_13(Probe) 10000.00 root test.t3.a, test.t3.b, test.t3.c, test.t3.d, cast(test.t3.a, decimal(20,0) BINARY)->DeferredCauset#13 22 └─TableReader_15 10000.00 root data:TableFullScan_14 23 └─TableFullScan_14 10000.00 cop[einsteindb] causet:t3 keep order:false, stats:pseudo 24 explain select * from t1; 25 id estRows task access object operator info 26 TableReader_5 10000.00 root data:TableFullScan_4 27 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 28 explain select * from t1 order by c2; 29 id estRows task access object operator info 30 IndexLookUp_12 10000.00 root 31 ├─IndexFullScan_10(Build) 10000.00 cop[einsteindb] causet:t1, index:c2(c2) keep order:true, stats:pseudo 32 └─TableRowIDScan_11(Probe) 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 33 explain select * from t2 order by c2; 34 id estRows task access object operator info 35 Sort_4 10000.00 root test.t2.c2 36 └─TableReader_8 10000.00 root data:TableFullScan_7 37 └─TableFullScan_7 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 38 explain select * from t1 where t1.c1 > 0; 39 id estRows task access object operator info 40 TableReader_6 3333.33 root data:TableRangeScan_5 41 └─TableRangeScan_5 3333.33 cop[einsteindb] causet:t1 range:(0,+inf], keep order:false, stats:pseudo 42 explain select t1.c1, t1.c2 from t1 where t1.c2 = 1; 43 id estRows task access object operator info 44 IndexReader_6 10.00 root index:IndexRangeScan_5 45 └─IndexRangeScan_5 10.00 cop[einsteindb] causet:t1, index:c2(c2) range:[1,1], keep order:false, stats:pseudo 46 explain select * from t1 left join t2 on t1.c2 = t2.c1 where t1.c1 > 1; 47 id estRows task access object operator info 48 HashJoin_23 4166.67 root left outer join, equal:[eq(test.t1.c2, test.t2.c1)] 49 ├─TableReader_33(Build) 3333.33 root data:TableRangeScan_32 50 │ └─TableRangeScan_32 3333.33 cop[einsteindb] causet:t1 range:(1,+inf], keep order:false, stats:pseudo 51 └─TableReader_36(Probe) 9990.00 root data:Selection_35 52 └─Selection_35 9990.00 cop[einsteindb] not(isnull(test.t2.c1)) 53 └─TableFullScan_34 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 54 explain uFIDelate t1 set t1.c2 = 2 where t1.c1 = 1; 55 id estRows task access object operator info 56 UFIDelate_2 N/A root N/A 57 └─Point_Get_1 1.00 root causet:t1 handle:1 58 explain delete from t1 where t1.c2 = 1; 59 id estRows task access object operator info 60 Delete_4 N/A root N/A 61 └─IndexLookUp_11 10.00 root 62 ├─IndexRangeScan_9(Build) 10.00 cop[einsteindb] causet:t1, index:c2(c2) range:[1,1], keep order:false, stats:pseudo 63 └─TableRowIDScan_10(Probe) 10.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 64 explain select count(b.c2) from t1 a, t2 b where a.c1 = b.c2 group by a.c1; 65 id estRows task access object operator info 66 Projection_11 9990.00 root cast(DeferredCauset#8, bigint(21) BINARY)->DeferredCauset#7 67 └─HashJoin_21 9990.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] 68 ├─HashAgg_28(Build) 7992.00 root group by:test.t2.c2, funcs:count(DeferredCauset#9)->DeferredCauset#8, funcs:firstrow(test.t2.c2)->test.t2.c2 69 │ └─TableReader_29 7992.00 root data:HashAgg_23 70 │ └─HashAgg_23 7992.00 cop[einsteindb] group by:test.t2.c2, funcs:count(test.t2.c2)->DeferredCauset#9 71 │ └─Selection_27 9990.00 cop[einsteindb] not(isnull(test.t2.c2)) 72 │ └─TableFullScan_26 10000.00 cop[einsteindb] causet:b keep order:false, stats:pseudo 73 └─TableReader_34(Probe) 10000.00 root data:TableFullScan_33 74 └─TableFullScan_33 10000.00 cop[einsteindb] causet:a keep order:false, stats:pseudo 75 explain select * from t2 order by t2.c2 limit 0, 1; 76 id estRows task access object operator info 77 TopN_7 1.00 root test.t2.c2, offset:0, count:1 78 └─TableReader_15 1.00 root data:TopN_14 79 └─TopN_14 1.00 cop[einsteindb] test.t2.c2, offset:0, count:1 80 └─TableFullScan_13 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 81 explain select * from t1 where c1 > 1 and c2 = 1 and c3 < 1; 82 id estRows task access object operator info 83 IndexLookUp_11 11.08 root 84 ├─IndexRangeScan_8(Build) 33.33 cop[einsteindb] causet:t1, index:c2(c2) range:(1 1,1 +inf], keep order:false, stats:pseudo 85 └─Selection_10(Probe) 11.08 cop[einsteindb] lt(test.t1.c3, 1) 86 └─TableRowIDScan_9 33.33 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 87 explain select * from t1 where c1 = 1 and c2 > 1; 88 id estRows task access object operator info 89 Selection_6 0.33 root gt(test.t1.c2, 1) 90 └─Point_Get_5 1.00 root causet:t1 handle:1 91 explain select sum(t1.c1 in (select c1 from t2)) from t1; 92 id estRows task access object operator info 93 StreamAgg_12 1.00 root funcs:sum(DeferredCauset#10)->DeferredCauset#8 94 └─Projection_23 10000.00 root cast(DeferredCauset#7, decimal(65,0) BINARY)->DeferredCauset#10 95 └─HashJoin_22 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.c1, test.t2.c1) 96 ├─IndexReader_21(Build) 10000.00 root index:IndexFullScan_20 97 │ └─IndexFullScan_20 10000.00 cop[einsteindb] causet:t2, index:c1(c1) keep order:false, stats:pseudo 98 └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 99 └─TableFullScan_14 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 100 explain select c1 from t1 where c1 in (select c2 from t2); 101 id estRows task access object operator info 102 HashJoin_19 9990.00 root inner join, equal:[eq(test.t1.c1, test.t2.c2)] 103 ├─HashAgg_23(Build) 7992.00 root group by:test.t2.c2, funcs:firstrow(test.t2.c2)->test.t2.c2 104 │ └─TableReader_30 9990.00 root data:Selection_29 105 │ └─Selection_29 9990.00 cop[einsteindb] not(isnull(test.t2.c2)) 106 │ └─TableFullScan_28 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 107 └─TableReader_32(Probe) 10000.00 root data:TableFullScan_31 108 └─TableFullScan_31 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 109 explain select (select count(1) k from t1 s where s.c1 = t1.c1 having k != 0) from t1; 110 id estRows task access object operator info 111 Projection_12 10000.00 root ifnull(DeferredCauset#7, 0)->DeferredCauset#7 112 └─MergeJoin_13 10000.00 root left outer join, left key:test.t1.c1, right key:test.t1.c1 113 ├─Projection_18(Build) 8000.00 root 1->DeferredCauset#7, test.t1.c1 114 │ └─TableReader_20 10000.00 root data:TableFullScan_19 115 │ └─TableFullScan_19 10000.00 cop[einsteindb] causet:s keep order:true, stats:pseudo 116 └─TableReader_17(Probe) 10000.00 root data:TableFullScan_16 117 └─TableFullScan_16 10000.00 cop[einsteindb] causet:t1 keep order:true, stats:pseudo 118 explain select * from information_schema.columns; 119 id estRows task access object operator info 120 MemTableScan_4 10000.00 root causet:COLUMNS 121 explain select c2 = (select c2 from t2 where t1.c1 = t2.c1 order by c1 limit 1) from t1; 122 id estRows task access object operator info 123 Projection_12 10000.00 root eq(test.t1.c2, test.t2.c2)->DeferredCauset#8 124 └─Apply_14 10000.00 root CARTESIAN left outer join 125 ├─TableReader_16(Build) 10000.00 root data:TableFullScan_15 126 │ └─TableFullScan_15 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 127 └─Projection_43(Probe) 1.00 root test.t2.c1, test.t2.c2 128 └─IndexLookUp_42 1.00 root limit embedded(offset:0, count:1) 129 ├─Limit_41(Build) 1.00 cop[einsteindb] offset:0, count:1 130 │ └─IndexRangeScan_39 1.00 cop[einsteindb] causet:t2, index:c1(c1) range: decided by [eq(test.t1.c1, test.t2.c1)], keep order:true, stats:pseudo 131 └─TableRowIDScan_40(Probe) 1.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 132 explain select * from t1 order by c1 desc limit 1; 133 id estRows task access object operator info 134 Limit_10 1.00 root offset:0, count:1 135 └─TableReader_20 1.00 root data:Limit_19 136 └─Limit_19 1.00 cop[einsteindb] offset:0, count:1 137 └─TableFullScan_18 1.00 cop[einsteindb] causet:t1 keep order:true, desc, stats:pseudo 138 explain select * from t4 use index(idx) where a > 1 and b > 1 and c > 1 limit 1; 139 id estRows task access object operator info 140 Limit_9 1.00 root offset:0, count:1 141 └─IndexLookUp_16 1.00 root 142 ├─Selection_13(Build) 3.00 cop[einsteindb] gt(test.t4.b, 1) 143 │ └─IndexRangeScan_11 9.00 cop[einsteindb] causet:t4, index:idx(a, b) range:(1,+inf], keep order:false, stats:pseudo 144 └─Limit_15(Probe) 1.00 cop[einsteindb] offset:0, count:1 145 └─Selection_14 1.00 cop[einsteindb] gt(test.t4.c, 1) 146 └─TableRowIDScan_12 3.00 cop[einsteindb] causet:t4 keep order:false, stats:pseudo 147 explain select * from t4 where a > 1 and c > 1 limit 1; 148 id estRows task access object operator info 149 Limit_8 1.00 root offset:0, count:1 150 └─TableReader_14 1.00 root data:Limit_13 151 └─Limit_13 1.00 cop[einsteindb] offset:0, count:1 152 └─Selection_12 1.00 cop[einsteindb] gt(test.t4.c, 1) 153 └─TableRangeScan_11 3.00 cop[einsteindb] causet:t4 range:(1,+inf], keep order:false, stats:pseudo 154 explain select ifnull(null, t1.c1) from t1; 155 id estRows task access object operator info 156 TableReader_5 10000.00 root data:TableFullScan_4 157 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 158 explain select if(10, t1.c1, t1.c2) from t1; 159 id estRows task access object operator info 160 TableReader_5 10000.00 root data:TableFullScan_4 161 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 162 explain select c1 from t2 union select c1 from t2 union all select c1 from t2; 163 id estRows task access object operator info 164 Union_17 26000.00 root 165 ├─HashAgg_21 16000.00 root group by:DeferredCauset#10, funcs:firstrow(DeferredCauset#12)->DeferredCauset#10 166 │ └─Union_22 16000.00 root 167 │ ├─StreamAgg_27 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->DeferredCauset#12, funcs:firstrow(test.t2.c1)->DeferredCauset#10 168 │ │ └─IndexReader_40 10000.00 root index:IndexFullScan_39 169 │ │ └─IndexFullScan_39 10000.00 cop[einsteindb] causet:t2, index:c1(c1) keep order:true, stats:pseudo 170 │ └─StreamAgg_45 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->DeferredCauset#12, funcs:firstrow(test.t2.c1)->DeferredCauset#10 171 │ └─IndexReader_58 10000.00 root index:IndexFullScan_57 172 │ └─IndexFullScan_57 10000.00 cop[einsteindb] causet:t2, index:c1(c1) keep order:true, stats:pseudo 173 └─IndexReader_63 10000.00 root index:IndexFullScan_62 174 └─IndexFullScan_62 10000.00 cop[einsteindb] causet:t2, index:c1(c1) keep order:false, stats:pseudo 175 explain select c1 from t2 union all select c1 from t2 union select c1 from t2; 176 id estRows task access object operator info 177 HashAgg_18 24000.00 root group by:DeferredCauset#10, funcs:firstrow(DeferredCauset#11)->DeferredCauset#10 178 └─Union_19 24000.00 root 179 ├─StreamAgg_24 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->DeferredCauset#11, funcs:firstrow(test.t2.c1)->DeferredCauset#10 180 │ └─IndexReader_37 10000.00 root index:IndexFullScan_36 181 │ └─IndexFullScan_36 10000.00 cop[einsteindb] causet:t2, index:c1(c1) keep order:true, stats:pseudo 182 ├─StreamAgg_42 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->DeferredCauset#11, funcs:firstrow(test.t2.c1)->DeferredCauset#10 183 │ └─IndexReader_55 10000.00 root index:IndexFullScan_54 184 │ └─IndexFullScan_54 10000.00 cop[einsteindb] causet:t2, index:c1(c1) keep order:true, stats:pseudo 185 └─StreamAgg_60 8000.00 root group by:test.t2.c1, funcs:firstrow(test.t2.c1)->DeferredCauset#11, funcs:firstrow(test.t2.c1)->DeferredCauset#10 186 └─IndexReader_73 10000.00 root index:IndexFullScan_72 187 └─IndexFullScan_72 10000.00 cop[einsteindb] causet:t2, index:c1(c1) keep order:true, stats:pseudo 188 select * from information_schema.milevadb_indexes where block_name='t4'; 189 TABLE_SCHEMA TABLE_NAME NON_UNIQUE KEY_NAME SEQ_IN_INDEX COLUMN_NAME SUB_PART INDEX_COMMENT Expression INDEX_ID IS_VISIBLE 190 test t4 0 PRIMARY 1 a NULL NULL 0 YES 191 test t4 1 idx 1 a NULL NULL 1 YES 192 test t4 1 idx 2 b NULL NULL 1 YES 193 test t4 1 expr_idx 1 NULL NULL (`a` + `b` + 1) 2 YES 194 explain select count(1) from (select count(1) from (select * from t1 where c3 = 100) k) k2; 195 id estRows task access object operator info 196 StreamAgg_13 1.00 root funcs:count(1)->DeferredCauset#5 197 └─StreamAgg_28 1.00 root funcs:firstrow(DeferredCauset#9)->DeferredCauset#7 198 └─TableReader_29 1.00 root data:StreamAgg_17 199 └─StreamAgg_17 1.00 cop[einsteindb] funcs:firstrow(1)->DeferredCauset#9 200 └─Selection_27 10.00 cop[einsteindb] eq(test.t1.c3, 100) 201 └─TableFullScan_26 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 202 explain select 1 from (select count(c2), count(c3) from t1) k; 203 id estRows task access object operator info 204 Projection_5 1.00 root 1->DeferredCauset#6 205 └─StreamAgg_21 1.00 root funcs:firstrow(DeferredCauset#14)->DeferredCauset#9 206 └─TableReader_22 1.00 root data:StreamAgg_9 207 └─StreamAgg_9 1.00 cop[einsteindb] funcs:firstrow(1)->DeferredCauset#14 208 └─TableFullScan_19 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 209 explain select count(1) from (select max(c2), count(c3) as m from t1) k; 210 id estRows task access object operator info 211 StreamAgg_11 1.00 root funcs:count(1)->DeferredCauset#6 212 └─StreamAgg_27 1.00 root funcs:firstrow(DeferredCauset#13)->DeferredCauset#8 213 └─TableReader_28 1.00 root data:StreamAgg_15 214 └─StreamAgg_15 1.00 cop[einsteindb] funcs:firstrow(1)->DeferredCauset#13 215 └─TableFullScan_25 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 216 explain select count(1) from (select count(c2) from t1 group by c3) k; 217 id estRows task access object operator info 218 StreamAgg_11 1.00 root funcs:count(1)->DeferredCauset#5 219 └─HashAgg_22 8000.00 root group by:test.t1.c3, funcs:firstrow(1)->DeferredCauset#7 220 └─TableReader_19 10000.00 root data:TableFullScan_18 221 └─TableFullScan_18 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 222 set @@stochastik.milevadb_opt_insubq_to_join_and_agg=0; 223 explain select sum(t1.c1 in (select c1 from t2)) from t1; 224 id estRows task access object operator info 225 StreamAgg_12 1.00 root funcs:sum(DeferredCauset#10)->DeferredCauset#8 226 └─Projection_23 10000.00 root cast(DeferredCauset#7, decimal(65,0) BINARY)->DeferredCauset#10 227 └─HashJoin_22 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.c1, test.t2.c1) 228 ├─IndexReader_21(Build) 10000.00 root index:IndexFullScan_20 229 │ └─IndexFullScan_20 10000.00 cop[einsteindb] causet:t2, index:c1(c1) keep order:false, stats:pseudo 230 └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 231 └─TableFullScan_14 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 232 explain select 1 in (select c2 from t2) from t1; 233 id estRows task access object operator info 234 HashJoin_7 10000.00 root CARTESIAN left outer semi join 235 ├─TableReader_14(Build) 10.00 root data:Selection_13 236 │ └─Selection_13 10.00 cop[einsteindb] eq(1, test.t2.c2) 237 │ └─TableFullScan_12 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 238 └─TableReader_9(Probe) 10000.00 root data:TableFullScan_8 239 └─TableFullScan_8 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 240 explain select sum(6 in (select c2 from t2)) from t1; 241 id estRows task access object operator info 242 StreamAgg_12 1.00 root funcs:sum(DeferredCauset#10)->DeferredCauset#8 243 └─Projection_22 10000.00 root cast(DeferredCauset#7, decimal(65,0) BINARY)->DeferredCauset#10 244 └─HashJoin_21 10000.00 root CARTESIAN left outer semi join 245 ├─TableReader_20(Build) 10.00 root data:Selection_19 246 │ └─Selection_19 10.00 cop[einsteindb] eq(6, test.t2.c2) 247 │ └─TableFullScan_18 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 248 └─TableReader_15(Probe) 10000.00 root data:TableFullScan_14 249 └─TableFullScan_14 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 250 explain format="dot" select sum(t1.c1 in (select c1 from t2)) from t1; 251 dot contents 252 253 digraph StreamAgg_12 { 254 subgraph cluster12{ 255 node [style=filled, color=lightgrey] 256 color=black 257 label = "root" 258 "StreamAgg_12" -> "Projection_23" 259 "Projection_23" -> "HashJoin_22" 260 "HashJoin_22" -> "TableReader_15" 261 "HashJoin_22" -> "IndexReader_21" 262 } 263 subgraph cluster14{ 264 node [style=filled, color=lightgrey] 265 color=black 266 label = "cop" 267 "TableFullScan_14" 268 } 269 subgraph cluster20{ 270 node [style=filled, color=lightgrey] 271 color=black 272 label = "cop" 273 "IndexFullScan_20" 274 } 275 "TableReader_15" -> "TableFullScan_14" 276 "IndexReader_21" -> "IndexFullScan_20" 277 } 278 279 explain format="dot" select 1 in (select c2 from t2) from t1; 280 dot contents 281 282 digraph HashJoin_7 { 283 subgraph cluster7{ 284 node [style=filled, color=lightgrey] 285 color=black 286 label = "root" 287 "HashJoin_7" -> "TableReader_9" 288 "HashJoin_7" -> "TableReader_14" 289 } 290 subgraph cluster8{ 291 node [style=filled, color=lightgrey] 292 color=black 293 label = "cop" 294 "TableFullScan_8" 295 } 296 subgraph cluster13{ 297 node [style=filled, color=lightgrey] 298 color=black 299 label = "cop" 300 "Selection_13" -> "TableFullScan_12" 301 } 302 "TableReader_9" -> "TableFullScan_8" 303 "TableReader_14" -> "Selection_13" 304 } 305 306 drop causet if exists t1, t2, t3, t4; 307 drop causet if exists t; 308 create causet t(a int primary key, b int, c int, index idx(b)); 309 explain select t.c in (select count(*) from t s ignore index(idx), t t1 where s.a = t.a and s.a = t1.a) from t; 310 id estRows task access object operator info 311 Projection_11 10000.00 root DeferredCauset#11 312 └─Apply_13 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, DeferredCauset#10) 313 ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 314 │ └─TableFullScan_14 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 315 └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->DeferredCauset#10 316 └─MergeJoin_54 12.50 root inner join, left key:test.t.a, right key:test.t.a 317 ├─TableReader_49(Build) 1.00 root data:TableRangeScan_48 318 │ └─TableRangeScan_48 1.00 cop[einsteindb] causet:t1 range: decided by [eq(test.t.a, test.t.a)], keep order:true, stats:pseudo 319 └─TableReader_47(Probe) 1.00 root data:TableRangeScan_46 320 └─TableRangeScan_46 1.00 cop[einsteindb] causet:s range: decided by [eq(test.t.a, test.t.a)], keep order:true, stats:pseudo 321 explain select t.c in (select count(*) from t s use index(idx), t t1 where s.b = t.a and s.a = t1.a) from t; 322 id estRows task access object operator info 323 Projection_11 10000.00 root DeferredCauset#11 324 └─Apply_13 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, DeferredCauset#10) 325 ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 326 │ └─TableFullScan_14 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 327 └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->DeferredCauset#10 328 └─IndexMergeJoin_46 12.50 root inner join, inner:TableReader_41, outer key:test.t.a, inner key:test.t.a 329 ├─IndexReader_33(Build) 10.00 root index:IndexRangeScan_32 330 │ └─IndexRangeScan_32 10.00 cop[einsteindb] causet:s, index:idx(b) range: decided by [eq(test.t.b, test.t.a)], keep order:false, stats:pseudo 331 └─TableReader_41(Probe) 1.00 root data:TableRangeScan_40 332 └─TableRangeScan_40 1.00 cop[einsteindb] causet:t1 range: decided by [test.t.a], keep order:true, stats:pseudo 333 explain select t.c in (select count(*) from t s use index(idx), t t1 where s.b = t.a and s.c = t1.a) from t; 334 id estRows task access object operator info 335 Projection_11 10000.00 root DeferredCauset#11 336 └─Apply_13 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, DeferredCauset#10) 337 ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 338 │ └─TableFullScan_14 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 339 └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->DeferredCauset#10 340 └─IndexMergeJoin_48 12.49 root inner join, inner:TableReader_43, outer key:test.t.c, inner key:test.t.a 341 ├─IndexLookUp_35(Build) 9.99 root 342 │ ├─IndexRangeScan_32(Build) 10.00 cop[einsteindb] causet:s, index:idx(b) range: decided by [eq(test.t.b, test.t.a)], keep order:false, stats:pseudo 343 │ └─Selection_34(Probe) 9.99 cop[einsteindb] not(isnull(test.t.c)) 344 │ └─TableRowIDScan_33 10.00 cop[einsteindb] causet:s keep order:false, stats:pseudo 345 └─TableReader_43(Probe) 1.00 root data:TableRangeScan_42 346 └─TableRangeScan_42 1.00 cop[einsteindb] causet:t1 range: decided by [test.t.c], keep order:true, stats:pseudo 347 insert into t values(1, 1, 1), (2, 2 ,2), (3, 3, 3), (4, 3, 4),(5,3,5); 348 analyze causet t; 349 explain select t.c in (select count(*) from t s, t t1 where s.b = t.a and s.b = 3 and s.a = t1.a) from t; 350 id estRows task access object operator info 351 Projection_11 5.00 root DeferredCauset#11 352 └─Apply_13 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, DeferredCauset#10) 353 ├─TableReader_15(Build) 5.00 root data:TableFullScan_14 354 │ └─TableFullScan_14 5.00 cop[einsteindb] causet:t keep order:false 355 └─StreamAgg_20(Probe) 1.00 root funcs:count(1)->DeferredCauset#10 356 └─MergeJoin_62 2.40 root inner join, left key:test.t.a, right key:test.t.a 357 ├─TableReader_52(Build) 4.00 root data:Selection_51 358 │ └─Selection_51 4.00 cop[einsteindb] eq(3, test.t.a) 359 │ └─TableFullScan_50 5.00 cop[einsteindb] causet:t1 keep order:true 360 └─IndexReader_49(Probe) 2.40 root index:Selection_48 361 └─Selection_48 2.40 cop[einsteindb] eq(3, test.t.a) 362 └─IndexRangeScan_47 3.00 cop[einsteindb] causet:s, index:idx(b) range:[3,3], keep order:true 363 explain select t.c in (select count(*) from t s left join t t1 on s.a = t1.a where 3 = t.a and s.b = 3) from t; 364 id estRows task access object operator info 365 Projection_10 5.00 root DeferredCauset#11 366 └─Apply_12 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, DeferredCauset#10) 367 ├─TableReader_14(Build) 5.00 root data:TableFullScan_13 368 │ └─TableFullScan_13 5.00 cop[einsteindb] causet:t keep order:false 369 └─StreamAgg_19(Probe) 1.00 root funcs:count(1)->DeferredCauset#10 370 └─MergeJoin_50 2.40 root left outer join, left key:test.t.a, right key:test.t.a 371 ├─TableReader_40(Build) 4.00 root data:Selection_39 372 │ └─Selection_39 4.00 cop[einsteindb] eq(3, test.t.a) 373 │ └─TableFullScan_38 5.00 cop[einsteindb] causet:t1 keep order:true 374 └─IndexReader_37(Probe) 2.40 root index:Selection_36 375 └─Selection_36 2.40 cop[einsteindb] eq(3, test.t.a) 376 └─IndexRangeScan_35 3.00 cop[einsteindb] causet:s, index:idx(b) range:[3,3], keep order:true 377 explain select t.c in (select count(*) from t s right join t t1 on s.a = t1.a where 3 = t.a and t1.b = 3) from t; 378 id estRows task access object operator info 379 Projection_10 5.00 root DeferredCauset#11 380 └─Apply_12 5.00 root CARTESIAN left outer semi join, other cond:eq(test.t.c, DeferredCauset#10) 381 ├─TableReader_14(Build) 5.00 root data:TableFullScan_13 382 │ └─TableFullScan_13 5.00 cop[einsteindb] causet:t keep order:false 383 └─StreamAgg_19(Probe) 1.00 root funcs:count(1)->DeferredCauset#10 384 └─MergeJoin_49 2.40 root right outer join, left key:test.t.a, right key:test.t.a 385 ├─TableReader_36(Build) 4.00 root data:Selection_35 386 │ └─Selection_35 4.00 cop[einsteindb] eq(3, test.t.a) 387 │ └─TableFullScan_34 5.00 cop[einsteindb] causet:s keep order:true 388 └─IndexReader_39(Probe) 2.40 root index:Selection_38 389 └─Selection_38 2.40 cop[einsteindb] eq(3, test.t.a) 390 └─IndexRangeScan_37 3.00 cop[einsteindb] causet:t1, index:idx(b) range:[3,3], keep order:true 391 drop causet if exists t; 392 create causet t(a int unsigned); 393 explain select t.a = '123455' from t; 394 id estRows task access object operator info 395 Projection_3 10000.00 root eq(test.t.a, 123455)->DeferredCauset#3 396 └─TableReader_5 10000.00 root data:TableFullScan_4 397 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 398 explain select t.a > '123455' from t; 399 id estRows task access object operator info 400 Projection_3 10000.00 root gt(test.t.a, 123455)->DeferredCauset#3 401 └─TableReader_5 10000.00 root data:TableFullScan_4 402 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 403 explain select t.a != '123455' from t; 404 id estRows task access object operator info 405 Projection_3 10000.00 root ne(test.t.a, 123455)->DeferredCauset#3 406 └─TableReader_5 10000.00 root data:TableFullScan_4 407 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 408 explain select t.a = 12345678912345678998789678687678.111 from t; 409 id estRows task access object operator info 410 Projection_3 10000.00 root 0->DeferredCauset#3 411 └─TableReader_5 10000.00 root data:TableFullScan_4 412 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 413 drop causet if exists t; 414 create causet t(a bigint, b bigint, index idx(a, b)); 415 explain select * from t where a in (1, 2) and a in (1, 3); 416 id estRows task access object operator info 417 IndexReader_6 10.00 root index:IndexRangeScan_5 418 └─IndexRangeScan_5 10.00 cop[einsteindb] causet:t, index:idx(a, b) range:[1,1], keep order:false, stats:pseudo 419 explain select * from t where b in (1, 2) and b in (1, 3); 420 id estRows task access object operator info 421 TableReader_7 10.00 root data:Selection_6 422 └─Selection_6 10.00 cop[einsteindb] in(test.t.b, 1, 2), in(test.t.b, 1, 3) 423 └─TableFullScan_5 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 424 explain select * from t where a = 1 and a = 1; 425 id estRows task access object operator info 426 IndexReader_6 10.00 root index:IndexRangeScan_5 427 └─IndexRangeScan_5 10.00 cop[einsteindb] causet:t, index:idx(a, b) range:[1,1], keep order:false, stats:pseudo 428 explain select * from t where a = 1 and a = 2; 429 id estRows task access object operator info 430 TableDual_5 0.00 root rows:0 431 explain select * from t where b = 1 and b = 2; 432 id estRows task access object operator info 433 TableDual_5 0.00 root rows:0 434 explain select * from t t1 join t t2 where t1.b = t2.b and t2.b is null; 435 id estRows task access object operator info 436 Projection_7 0.00 root test.t.a, test.t.b, test.t.a, test.t.b 437 └─HashJoin_9 0.00 root inner join, equal:[eq(test.t.b, test.t.b)] 438 ├─TableReader_12(Build) 0.00 root data:Selection_11 439 │ └─Selection_11 0.00 cop[einsteindb] isnull(test.t.b), not(isnull(test.t.b)) 440 │ └─TableFullScan_10 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 441 └─TableReader_18(Probe) 9990.00 root data:Selection_17 442 └─Selection_17 9990.00 cop[einsteindb] not(isnull(test.t.b)) 443 └─TableFullScan_16 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 444 explain select * from t t1 where not exists (select * from t t2 where t1.b = t2.b); 445 id estRows task access object operator info 446 HashJoin_9 8000.00 root anti semi join, equal:[eq(test.t.b, test.t.b)] 447 ├─TableReader_15(Build) 10000.00 root data:TableFullScan_14 448 │ └─TableFullScan_14 10000.00 cop[einsteindb] causet:t2 keep order:false, stats:pseudo 449 └─TableReader_11(Probe) 10000.00 root data:TableFullScan_10 450 └─TableFullScan_10 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 451 drop causet if exists t; 452 create causet t(a bigint primary key); 453 explain select * from t where a = 1 and a = 2; 454 id estRows task access object operator info 455 TableDual_5 0.00 root rows:0 456 explain select null or a > 1 from t; 457 id estRows task access object operator info 458 Projection_3 10000.00 root or(<nil>, gt(test.t.a, 1))->DeferredCauset#2 459 └─TableReader_5 10000.00 root data:TableFullScan_4 460 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 461 explain select * from t where a = 1 for uFIDelate; 462 id estRows task access object operator info 463 Point_Get_1 1.00 root causet:t handle:1, dagger 464 drop causet if exists ta, tb; 465 create causet ta (a varchar(20)); 466 create causet tb (a varchar(20)); 467 begin; 468 insert tb values ('1'); 469 explain select * from ta where a = 1; 470 id estRows task access object operator info 471 TableReader_7 8000.00 root data:Selection_6 472 └─Selection_6 8000.00 cop[einsteindb] eq(cast(test.ta.a), 1) 473 └─TableFullScan_5 10000.00 cop[einsteindb] causet:ta keep order:false, stats:pseudo 474 rollback; 475 drop causet if exists t1, t2; 476 create causet t1(a int, b int, c int, primary key(a, b)); 477 create causet t2(a int, b int, c int, primary key(a)); 478 explain select t1.a, t1.b from t1 left outer join t2 on t1.a = t2.a; 479 id estRows task access object operator info 480 IndexReader_9 10000.00 root index:IndexFullScan_8 481 └─IndexFullScan_8 10000.00 cop[einsteindb] causet:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo 482 explain select distinct t1.a, t1.b from t1 left outer join t2 on t1.a = t2.a; 483 id estRows task access object operator info 484 IndexReader_11 10000.00 root index:IndexFullScan_10 485 └─IndexFullScan_10 10000.00 cop[einsteindb] causet:t1, index:PRIMARY(a, b) keep order:false, stats:pseudo 486 CREATE TABLE `test01` ( 487 `id` bigint(20) NOT NULL AUTO_INCREMENT, 488 `stat_date` int(11) NOT NULL DEFAULT '0', 489 `show_date` varchar(20) NOT NULL DEFAULT '', 490 `region_id` bigint(20) unsigned NOT NULL DEFAULT '0', 491 `period` tinyint(3) unsigned NOT NULL DEFAULT '0', 492 `registration_num` bigint(20) unsigned NOT NULL DEFAULT '0', 493 PRIMARY KEY (`id`) 494 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 495 CREATE TABLE `test02` ( 496 `id` bigint(20) NOT NULL AUTO_INCREMENT, 497 `region_name` varchar(128) DEFAULT NULL, 498 PRIMARY KEY (`id`) 499 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 500 EXPLAIN SELECT COUNT(1) FROM (SELECT COALESCE(b.region_name, '不详') region_name, SUM(a.registration_num) registration_num FROM (SELECT stat_date, show_date, region_id, 0 registration_num FROM test01 WHERE period = 1 AND stat_date >= 20191202 AND stat_date <= 20191202 UNION ALL SELECT stat_date, show_date, region_id, registration_num registration_num FROM test01 WHERE period = 1 AND stat_date >= 20191202 AND stat_date <= 20191202) a LEFT JOIN test02 b ON a.region_id = b.id WHERE registration_num > 0 AND a.stat_date >= '20191202' AND a.stat_date <= '20191202' GROUP BY a.stat_date , a.show_date , COALESCE(b.region_name, '不详') ) JLS; 501 id estRows task access object operator info 502 StreamAgg_22 1.00 root funcs:count(1)->DeferredCauset#22 503 └─HashAgg_25 1.00 root group by:DeferredCauset#32, DeferredCauset#33, DeferredCauset#34, funcs:firstrow(1)->DeferredCauset#31 504 └─Projection_46 0.01 root DeferredCauset#14, DeferredCauset#15, coalesce(test.test02.region_name, 不详)->DeferredCauset#34 505 └─IndexMergeJoin_34 0.01 root left outer join, inner:TableReader_29, outer key:DeferredCauset#16, inner key:test.test02.id 506 ├─Union_37(Build) 0.01 root 507 │ ├─Projection_38 0.00 root test.test01.stat_date, test.test01.show_date, test.test01.region_id 508 │ │ └─TableDual_39 0.00 root rows:0 509 │ └─Projection_40 0.01 root test.test01.stat_date, test.test01.show_date, test.test01.region_id 510 │ └─TableReader_43 0.01 root data:Selection_42 511 │ └─Selection_42 0.01 cop[einsteindb] eq(test.test01.period, 1), ge(test.test01.stat_date, 20191202), ge(test.test01.stat_date, 20191202), gt(cast(test.test01.registration_num), 0), le(test.test01.stat_date, 20191202), le(test.test01.stat_date, 20191202) 512 │ └─TableFullScan_41 10000.00 cop[einsteindb] causet:test01 keep order:false, stats:pseudo 513 └─TableReader_29(Probe) 1.00 root data:TableRangeScan_28 514 └─TableRangeScan_28 1.00 cop[einsteindb] causet:b range: decided by [DeferredCauset#16], keep order:true, stats:pseudo 515 drop causet if exists t; 516 create causet t(a int, nb int not null, nc int not null); 517 explain select ifnull(a, 0) from t; 518 id estRows task access object operator info 519 Projection_3 10000.00 root ifnull(test.t.a, 0)->DeferredCauset#5 520 └─TableReader_5 10000.00 root data:TableFullScan_4 521 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 522 explain select ifnull(nb, 0) from t; 523 id estRows task access object operator info 524 TableReader_5 10000.00 root data:TableFullScan_4 525 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 526 explain select ifnull(nb, 0), ifnull(nc, 0) from t; 527 id estRows task access object operator info 528 TableReader_5 10000.00 root data:TableFullScan_4 529 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 530 explain select ifnull(a, 0), ifnull(nb, 0) from t; 531 id estRows task access object operator info 532 Projection_3 10000.00 root ifnull(test.t.a, 0)->DeferredCauset#5, test.t.nb 533 └─TableReader_5 10000.00 root data:TableFullScan_4 534 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 535 explain select ifnull(nb, 0), ifnull(nb, 0) from t; 536 id estRows task access object operator info 537 Projection_3 10000.00 root test.t.nb, test.t.nb 538 └─TableReader_5 10000.00 root data:TableFullScan_4 539 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 540 explain select 1+ifnull(nb, 0) from t; 541 id estRows task access object operator info 542 Projection_3 10000.00 root plus(1, test.t.nb)->DeferredCauset#5 543 └─TableReader_5 10000.00 root data:TableFullScan_4 544 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 545 explain select 1+ifnull(a, 0) from t; 546 id estRows task access object operator info 547 Projection_3 10000.00 root plus(1, ifnull(test.t.a, 0))->DeferredCauset#5 548 └─TableReader_5 10000.00 root data:TableFullScan_4 549 └─TableFullScan_4 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 550 explain select 1+ifnull(nb, 0) from t where nb=1; 551 id estRows task access object operator info 552 Projection_4 10.00 root plus(1, test.t.nb)->DeferredCauset#5 553 └─TableReader_7 10.00 root data:Selection_6 554 └─Selection_6 10.00 cop[einsteindb] eq(test.t.nb, 1) 555 └─TableFullScan_5 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 556 explain select * from t ta left outer join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(ta.nb, 1) or ta.nb is null; 557 id estRows task access object operator info 558 HashJoin_7 8320.83 root left outer join, equal:[eq(test.t.nb, test.t.nb)], left cond:[gt(test.t.a, 1)] 559 ├─TableReader_13(Build) 10000.00 root data:TableFullScan_12 560 │ └─TableFullScan_12 10000.00 cop[einsteindb] causet:tb keep order:false, stats:pseudo 561 └─TableReader_11(Probe) 6656.67 root data:Selection_10 562 └─Selection_10 6656.67 cop[einsteindb] or(test.t.nb, isnull(test.t.nb)) 563 └─TableFullScan_9 10000.00 cop[einsteindb] causet:ta keep order:false, stats:pseudo 564 explain select * from t ta right outer join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(tb.nb, 1) or tb.nb is null; 565 id estRows task access object operator info 566 HashJoin_7 6656.67 root right outer join, equal:[eq(test.t.nb, test.t.nb)] 567 ├─TableReader_11(Build) 3333.33 root data:Selection_10 568 │ └─Selection_10 3333.33 cop[einsteindb] gt(test.t.a, 1) 569 │ └─TableFullScan_9 10000.00 cop[einsteindb] causet:ta keep order:false, stats:pseudo 570 └─TableReader_14(Probe) 6656.67 root data:Selection_13 571 └─Selection_13 6656.67 cop[einsteindb] or(test.t.nb, isnull(test.t.nb)) 572 └─TableFullScan_12 10000.00 cop[einsteindb] causet:tb keep order:false, stats:pseudo 573 explain select * from t ta inner join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(tb.nb, 1) or tb.nb is null; 574 id estRows task access object operator info 575 HashJoin_9 4166.67 root inner join, equal:[eq(test.t.nb, test.t.nb)] 576 ├─TableReader_12(Build) 3333.33 root data:Selection_11 577 │ └─Selection_11 3333.33 cop[einsteindb] gt(test.t.a, 1) 578 │ └─TableFullScan_10 10000.00 cop[einsteindb] causet:ta keep order:false, stats:pseudo 579 └─TableReader_15(Probe) 6656.67 root data:Selection_14 580 └─Selection_14 6656.67 cop[einsteindb] or(test.t.nb, isnull(test.t.nb)) 581 └─TableFullScan_13 10000.00 cop[einsteindb] causet:tb keep order:false, stats:pseudo 582 explain select ifnull(t.nc, 1) in (select count(*) from t s , t t1 where s.a = t.a and s.a = t1.a) from t; 583 id estRows task access object operator info 584 Projection_12 10000.00 root DeferredCauset#14 585 └─Apply_14 10000.00 root left outer semi join, equal:[eq(test.t.nc, DeferredCauset#13)] 586 ├─TableReader_16(Build) 10000.00 root data:TableFullScan_15 587 │ └─TableFullScan_15 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 588 └─HashAgg_19(Probe) 1.00 root funcs:count(DeferredCauset#15)->DeferredCauset#13 589 └─HashJoin_20 9.99 root inner join, equal:[eq(test.t.a, test.t.a)] 590 ├─HashAgg_30(Build) 7.99 root group by:test.t.a, funcs:count(DeferredCauset#16)->DeferredCauset#15, funcs:firstrow(test.t.a)->test.t.a 591 │ └─TableReader_31 7.99 root data:HashAgg_25 592 │ └─HashAgg_25 7.99 cop[einsteindb] group by:test.t.a, funcs:count(1)->DeferredCauset#16 593 │ └─Selection_29 9.99 cop[einsteindb] eq(test.t.a, test.t.a), not(isnull(test.t.a)) 594 │ └─TableFullScan_28 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 595 └─TableReader_24(Probe) 9.99 root data:Selection_23 596 └─Selection_23 9.99 cop[einsteindb] eq(test.t.a, test.t.a), not(isnull(test.t.a)) 597 └─TableFullScan_22 10000.00 cop[einsteindb] causet:s keep order:false, stats:pseudo 598 explain select * from t ta left outer join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(tb.a, 1) or tb.a is null; 599 id estRows task access object operator info 600 Selection_7 10000.00 root or(ifnull(test.t.a, 1), isnull(test.t.a)) 601 └─HashJoin_8 12500.00 root left outer join, equal:[eq(test.t.nb, test.t.nb)], left cond:[gt(test.t.a, 1)] 602 ├─TableReader_13(Build) 10000.00 root data:TableFullScan_12 603 │ └─TableFullScan_12 10000.00 cop[einsteindb] causet:tb keep order:false, stats:pseudo 604 └─TableReader_11(Probe) 10000.00 root data:TableFullScan_10 605 └─TableFullScan_10 10000.00 cop[einsteindb] causet:ta keep order:false, stats:pseudo 606 explain select * from t ta right outer join t tb on ta.nb = tb.nb and ta.a > 1 where ifnull(tb.a, 1) or tb.a is null; 607 id estRows task access object operator info 608 HashJoin_7 8002.00 root right outer join, equal:[eq(test.t.nb, test.t.nb)] 609 ├─TableReader_11(Build) 3333.33 root data:Selection_10 610 │ └─Selection_10 3333.33 cop[einsteindb] gt(test.t.a, 1) 611 │ └─TableFullScan_9 10000.00 cop[einsteindb] causet:ta keep order:false, stats:pseudo 612 └─TableReader_14(Probe) 8002.00 root data:Selection_13 613 └─Selection_13 8002.00 cop[einsteindb] or(ifnull(test.t.a, 1), isnull(test.t.a)) 614 └─TableFullScan_12 10000.00 cop[einsteindb] causet:tb keep order:false, stats:pseudo 615 explain select ifnull(t.a, 1) in (select count(*) from t s , t t1 where s.a = t.a and s.a = t1.a) from t; 616 id estRows task access object operator info 617 Projection_12 10000.00 root DeferredCauset#14 618 └─Apply_14 10000.00 root CARTESIAN left outer semi join, other cond:eq(ifnull(test.t.a, 1), DeferredCauset#13) 619 ├─TableReader_16(Build) 10000.00 root data:TableFullScan_15 620 │ └─TableFullScan_15 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 621 └─HashAgg_19(Probe) 1.00 root funcs:count(DeferredCauset#15)->DeferredCauset#13 622 └─HashJoin_20 9.99 root inner join, equal:[eq(test.t.a, test.t.a)] 623 ├─HashAgg_30(Build) 7.99 root group by:test.t.a, funcs:count(DeferredCauset#16)->DeferredCauset#15, funcs:firstrow(test.t.a)->test.t.a 624 │ └─TableReader_31 7.99 root data:HashAgg_25 625 │ └─HashAgg_25 7.99 cop[einsteindb] group by:test.t.a, funcs:count(1)->DeferredCauset#16 626 │ └─Selection_29 9.99 cop[einsteindb] eq(test.t.a, test.t.a), not(isnull(test.t.a)) 627 │ └─TableFullScan_28 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 628 └─TableReader_24(Probe) 9.99 root data:Selection_23 629 └─Selection_23 9.99 cop[einsteindb] eq(test.t.a, test.t.a), not(isnull(test.t.a)) 630 └─TableFullScan_22 10000.00 cop[einsteindb] causet:s keep order:false, stats:pseudo 631 drop causet if exists t; 632 create causet t(a int); 633 explain select * from t where _milevadb_rowid = 0; 634 id estRows task access object operator info 635 Point_Get_1 1.00 root causet:t handle:0 636 explain select * from t where _milevadb_rowid > 0; 637 id estRows task access object operator info 638 Projection_4 8000.00 root test.t.a 639 └─TableReader_6 10000.00 root data:TableRangeScan_5 640 └─TableRangeScan_5 10000.00 cop[einsteindb] causet:t range:(0,+inf], keep order:false, stats:pseudo 641 explain select a, _milevadb_rowid from t where a > 0; 642 id estRows task access object operator info 643 TableReader_7 3333.33 root data:Selection_6 644 └─Selection_6 3333.33 cop[einsteindb] gt(test.t.a, 0) 645 └─TableFullScan_5 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 646 explain select * from t where _milevadb_rowid > 0 and a > 0; 647 id estRows task access object operator info 648 Projection_4 2666.67 root test.t.a 649 └─TableReader_7 2666.67 root data:Selection_6 650 └─Selection_6 2666.67 cop[einsteindb] gt(test.t.a, 0) 651 └─TableRangeScan_5 3333.33 cop[einsteindb] causet:t range:(0,+inf], keep order:false, stats:pseudo 652 drop causet if exists t; 653 create causet t(a int, b int, c int); 654 explain select * from (select * from t order by (select 2)) t order by a, b; 655 id estRows task access object operator info 656 Sort_12 10000.00 root test.t.a, test.t.b 657 └─TableReader_18 10000.00 root data:TableFullScan_17 658 └─TableFullScan_17 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 659 explain select * from (select * from t order by c) t order by a, b; 660 id estRows task access object operator info 661 Sort_6 10000.00 root test.t.a, test.t.b 662 └─Sort_9 10000.00 root test.t.c 663 └─TableReader_12 10000.00 root data:TableFullScan_11 664 └─TableFullScan_11 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 665 drop causet if exists t; 666 set @@stochastik.milevadb_opt_insubq_to_join_and_agg=1; 667 explain SELECT 0 AS a FROM dual UNION SELECT 1 AS a FROM dual ORDER BY a; 668 id estRows task access object operator info 669 Sort_13 2.00 root DeferredCauset#3 670 └─HashAgg_17 2.00 root group by:DeferredCauset#3, funcs:firstrow(DeferredCauset#6)->DeferredCauset#3 671 └─Union_18 2.00 root 672 ├─HashAgg_19 1.00 root group by:1, funcs:firstrow(0)->DeferredCauset#6, funcs:firstrow(0)->DeferredCauset#3 673 │ └─TableDual_22 1.00 root rows:1 674 └─HashAgg_25 1.00 root group by:1, funcs:firstrow(1)->DeferredCauset#6, funcs:firstrow(1)->DeferredCauset#3 675 └─TableDual_28 1.00 root rows:1 676 explain SELECT 0 AS a FROM dual UNION (SELECT 1 AS a FROM dual ORDER BY a); 677 id estRows task access object operator info 678 HashAgg_15 2.00 root group by:DeferredCauset#3, funcs:firstrow(DeferredCauset#6)->DeferredCauset#3 679 └─Union_16 2.00 root 680 ├─HashAgg_17 1.00 root group by:1, funcs:firstrow(0)->DeferredCauset#6, funcs:firstrow(0)->DeferredCauset#3 681 │ └─TableDual_20 1.00 root rows:1 682 └─StreamAgg_27 1.00 root group by:DeferredCauset#2, funcs:firstrow(DeferredCauset#2)->DeferredCauset#6, funcs:firstrow(DeferredCauset#2)->DeferredCauset#3 683 └─Projection_32 1.00 root 1->DeferredCauset#2 684 └─TableDual_33 1.00 root rows:1 685 create causet t (i int key, j int, unique key (i, j)); 686 begin; 687 insert into t values (1, 1); 688 explain uFIDelate t set j = -j where i = 1 and j = 1; 689 id estRows task access object operator info 690 UFIDelate_2 N/A root N/A 691 └─Point_Get_1 1.00 root causet:t, index:i(i, j) 692 rollback; 693 drop causet if exists t; 694 create causet t(a int); 695 begin; 696 insert into t values (1); 697 explain select * from t left outer join t t1 on t.a = t1.a where t.a not between 1 and 2; 698 id estRows task access object operator info 699 HashJoin_9 8320.83 root left outer join, equal:[eq(test.t.a, test.t.a)] 700 ├─UnionScan_15(Build) 6656.67 root not(and(ge(test.t.a, 1), le(test.t.a, 2))), not(isnull(test.t.a)) 701 │ └─TableReader_18 6656.67 root data:Selection_17 702 │ └─Selection_17 6656.67 cop[einsteindb] not(isnull(test.t.a)), or(lt(test.t.a, 1), gt(test.t.a, 2)) 703 │ └─TableFullScan_16 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 704 └─UnionScan_11(Probe) 6656.67 root not(and(ge(test.t.a, 1), le(test.t.a, 2))) 705 └─TableReader_14 6656.67 root data:Selection_13 706 └─Selection_13 6656.67 cop[einsteindb] or(lt(test.t.a, 1), gt(test.t.a, 2)) 707 └─TableFullScan_12 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 708 rollback; 709 drop causet if exists t; 710 create causet t(a time, b date); 711 insert into t values (1, "1000-01-01"), (2, "1000-01-02"), (3, "1000-01-03"); 712 analyze causet t; 713 explain select * from t where a = 1; 714 id estRows task access object operator info 715 TableReader_7 1.00 root data:Selection_6 716 └─Selection_6 1.00 cop[einsteindb] eq(test.t.a, 00:00:01.000000) 717 └─TableFullScan_5 3.00 cop[einsteindb] causet:t keep order:false 718 explain select * from t where b = "1000-01-01"; 719 id estRows task access object operator info 720 TableReader_7 1.00 root data:Selection_6 721 └─Selection_6 1.00 cop[einsteindb] eq(test.t.b, 1000-01-01 00:00:00.000000) 722 └─TableFullScan_5 3.00 cop[einsteindb] causet:t keep order:false 723 drop causet t; 724 create causet t(a int); 725 insert into t values (1),(2),(2),(2),(9),(9),(9),(10); 726 analyze causet t with 1 buckets; 727 explain select * from t where a >= 3 and a <= 8; 728 id estRows task access object operator info 729 TableReader_7 0.00 root data:Selection_6 730 └─Selection_6 0.00 cop[einsteindb] ge(test.t.a, 3), le(test.t.a, 8) 731 └─TableFullScan_5 8.00 cop[einsteindb] causet:t keep order:false 732 drop causet t; 733 create causet t(a int, b int, index idx_ab(a, b)); 734 explain select a, b from t where a in (1) order by b; 735 id estRows task access object operator info 736 IndexReader_12 10.00 root index:IndexRangeScan_11 737 └─IndexRangeScan_11 10.00 cop[einsteindb] causet:t, index:idx_ab(a, b) range:[1,1], keep order:true, stats:pseudo 738 explain select a, b from t where a = 1 order by b; 739 id estRows task access object operator info 740 IndexReader_12 10.00 root index:IndexRangeScan_11 741 └─IndexRangeScan_11 10.00 cop[einsteindb] causet:t, index:idx_ab(a, b) range:[1,1], keep order:true, stats:pseudo 742 drop causet if exists t; 743 create causet t(a int, b int); 744 explain select a, b from (select a, b, avg(b) over (partition by a)as avg_b from t) as tt where a > 10 and b < 10 and a > avg_b; 745 id estRows task access object operator info 746 Projection_8 2666.67 root test.t.a, test.t.b 747 └─Selection_9 2666.67 root gt(cast(test.t.a), DeferredCauset#5), lt(test.t.b, 10) 748 └─Window_10 3333.33 root avg(cast(test.t.b, decimal(65,4) BINARY))->DeferredCauset#5 over(partition by test.t.a) 749 └─Sort_14 3333.33 root test.t.a 750 └─TableReader_13 3333.33 root data:Selection_12 751 └─Selection_12 3333.33 cop[einsteindb] gt(test.t.a, 10) 752 └─TableFullScan_11 10000.00 cop[einsteindb] causet:t keep order:false, stats:pseudo 753 drop causet if exists t; 754 create causet t(a int, b int); 755 explain format="dot" select * from t where a < 2; 756 dot contents 757 758 digraph TableReader_7 { 759 subgraph cluster7{ 760 node [style=filled, color=lightgrey] 761 color=black 762 label = "root" 763 "TableReader_7" 764 } 765 subgraph cluster6{ 766 node [style=filled, color=lightgrey] 767 color=black 768 label = "cop" 769 "Selection_6" -> "TableFullScan_5" 770 } 771 "TableReader_7" -> "Selection_6" 772 } 773 774 drop causet if exists t; 775 create causet t(a binary(16) not null, b varchar(2) default null, c varchar(100) default 'aaaa', key (a,b)); 776 explain select * from t where a=x'FA34E1093CB428485734E3917F000000' and b='xb'; 777 id estRows task access object operator info 778 IndexLookUp_10 0.10 root 779 ├─IndexRangeScan_8(Build) 0.10 cop[einsteindb] causet:t, index:a(a, b) range:["[250 52 225 9 60 180 40 72 87 52 227 145 127 0 0 0]" "xb","[250 52 225 9 60 180 40 72 87 52 227 145 127 0 0 0]" "xb"], keep order:false, stats:pseudo 780 └─TableRowIDScan_9(Probe) 0.10 cop[einsteindb] causet:t keep order:false, stats:pseudo 781 explain uFIDelate t set c = 'ssss' where a=x'FA34E1093CB428485734E3917F000000' and b='xb'; 782 id estRows task access object operator info 783 UFIDelate_4 N/A root N/A 784 └─IndexLookUp_11 0.10 root 785 ├─IndexRangeScan_9(Build) 0.10 cop[einsteindb] causet:t, index:a(a, b) range:["[250 52 225 9 60 180 40 72 87 52 227 145 127 0 0 0]" "xb","[250 52 225 9 60 180 40 72 87 52 227 145 127 0 0 0]" "xb"], keep order:false, stats:pseudo 786 └─TableRowIDScan_10(Probe) 0.10 cop[einsteindb] causet:t keep order:false, stats:pseudo 787 drop causet if exists t;