1
drop table if exists t1, t2, t3, t1i, t2i, t3i;
2
create table t1 (a1 char(8), a2 char(8));
3
create temporary table t2 (b1 char(8), b2 char(8)) ENGINE=MyISAM;
4
create table t3 (c1 char(8), c2 char(8));
5
insert into t1 values ('1 - 00', '2 - 00');
6
insert into t1 values ('1 - 01', '2 - 01');
7
insert into t1 values ('1 - 02', '2 - 02');
8
insert into t2 values ('1 - 01', '2 - 01');
9
insert into t2 values ('1 - 01', '2 - 01');
10
insert into t2 values ('1 - 02', '2 - 02');
11
insert into t2 values ('1 - 02', '2 - 02');
12
insert into t2 values ('1 - 03', '2 - 03');
13
insert into t3 values ('1 - 01', '2 - 01');
14
insert into t3 values ('1 - 02', '2 - 02');
15
insert into t3 values ('1 - 03', '2 - 03');
16
insert into t3 values ('1 - 04', '2 - 04');
17
create temporary table t1i (a1 char(8), a2 char(8)) ENGINE=MyISAM;
18
create table t2i (b1 char(8), b2 char(8));
19
create temporary table t3i (c1 char(8), c2 char(8)) ENGINE=MyISAM;
20
create index it1i1 on t1i (a1);
21
create index it1i2 on t1i (a2);
22
create index it1i3 on t1i (a1, a2);
23
create index it2i1 on t2i (b1);
24
create index it2i2 on t2i (b2);
25
create index it2i3 on t2i (b1, b2);
26
create index it3i1 on t3i (c1);
27
create index it3i2 on t3i (c2);
28
create index it3i3 on t3i (c1, c2);
29
insert into t1i select * from t1;
30
insert into t2i select * from t2;
31
insert into t3i select * from t3;
32
/********************************************************************
34
********************************************************************/
35
# non-indexed nullable fields
37
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
38
id select_type table type possible_keys key key_len ref rows filtered Extra
39
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
40
2 SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00 Using where
42
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` AS `b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key)))
43
select * from t1 where a1 in (select b1 from t2 where b1 > '0');
48
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
49
id select_type table type possible_keys key key_len ref rows filtered Extra
50
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
51
2 SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00 Using where; Using temporary; Using filesort
53
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` AS `b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key)))
54
select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1);
59
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
60
id select_type table type possible_keys key key_len ref rows filtered Extra
61
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
62
2 SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00 Using where; Using temporary; Using filesort
64
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key)))
65
select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2);
70
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
71
id select_type table type possible_keys key key_len ref rows filtered Extra
72
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
73
2 SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00 Using where; Using temporary; Using filesort
75
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1` AS `b1`,min(`test`.`t2`.`b2`) AS `min(b2)` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key)))
76
select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1);
81
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
82
id select_type table type possible_keys key key_len ref rows filtered Extra
83
1 PRIMARY t1i index NULL it1i3 70 NULL # 100.00 Using where; Using index
84
2 SUBQUERY t2i ALL it2i1,it2i3 NULL NULL NULL # 100.00 Using where
86
Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` AS `b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key)))
87
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
92
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
93
id select_type table type possible_keys key key_len ref rows filtered Extra
94
1 PRIMARY t1i index NULL it1i3 70 NULL # 100.00 Using where; Using index
95
2 SUBQUERY t2i ALL it2i1,it2i3 NULL NULL NULL # 100.00 Using where; Using temporary; Using filesort
97
Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` AS `b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key)))
98
select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1);
103
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
104
id select_type table type possible_keys key key_len ref rows filtered Extra
105
1 PRIMARY t1i index NULL it1i3 70 NULL # 100.00 Using where; Using index
106
2 SUBQUERY t2i ALL it2i1,it2i3 NULL NULL NULL # 100.00 Using where
108
Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key)))
109
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
114
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
115
id select_type table type possible_keys key key_len ref rows filtered Extra
116
1 PRIMARY t1i index NULL it1i3 70 NULL # 100.00 Using where; Using index
117
2 SUBQUERY t2i ALL it2i1,it2i3 NULL NULL NULL # 100.00 Using where; Using temporary; Using filesort
119
Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key)))
120
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2);
125
select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
126
id select_type table type possible_keys key key_len ref rows filtered Extra
127
1 PRIMARY t1i index NULL it1i3 70 NULL # 100.00 Using where; Using index
128
2 SUBQUERY t2i ALL it2i1,it2i3 NULL NULL NULL # 100.00 Using where; Using temporary; Using filesort
130
Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,min(`test`.`t2i`.`b2`) AS `min(b2)` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key)))
131
select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1);
136
select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
137
id select_type table type possible_keys key key_len ref rows filtered Extra
138
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
139
2 SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00
141
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2` from `test`.`t2` order by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key)))
142
select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2);
147
select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
148
id select_type table type possible_keys key key_len ref rows filtered Extra
149
1 PRIMARY t1i index NULL it1i3 70 NULL # 100.00 Using where; Using index
150
2 SUBQUERY t2i ALL NULL NULL NULL NULL # 100.00
152
Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` order by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key)))
153
select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2);
159
where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
160
(a1, a2) in (select c1, c2 from t3
161
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
162
id select_type table type possible_keys key key_len ref rows filtered Extra
163
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
164
3 SUBQUERY t3 ALL NULL NULL NULL NULL # 100.00 Using where
165
4 SUBQUERY t2i ALL it2i2 NULL NULL NULL # 100.00 Using where
166
2 SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00 Using where
168
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key))))
170
where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and
171
(a1, a2) in (select c1, c2 from t3
172
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
178
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
179
(a1, a2) in (select c1, c2 from t3i
180
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
181
id select_type table type possible_keys key key_len ref rows filtered Extra
182
1 PRIMARY t1i index NULL it1i3 70 NULL # 100.00 Using where; Using index
183
3 SUBQUERY t3i index NULL it3i3 70 NULL # 100.00 Using where; Using index
184
4 SUBQUERY t2i ALL it2i2 NULL NULL NULL # 100.00 Using where
185
2 SUBQUERY t2i ALL it2i1,it2i3 NULL NULL NULL # 100.00 Using where
187
Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key))) and <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1` AS `c1`,`test`.`t3i`.`c2` AS `c2` from `test`.`t3i` where <in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key))))
189
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
190
(a1, a2) in (select c1, c2 from t3i
191
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
197
where (a1, a2) in (select b1, b2 from t2
198
where b2 in (select c2 from t3 where c2 LIKE '%02') or
199
b2 in (select c2 from t3 where c2 LIKE '%03')) and
200
(a1, a2) in (select c1, c2 from t3
201
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
202
id select_type table type possible_keys key key_len ref rows filtered Extra
203
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
204
5 SUBQUERY t3 ALL NULL NULL NULL NULL # 100.00 Using where
205
6 SUBQUERY t2i ALL it2i2 NULL NULL NULL # 100.00 Using where
206
2 SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00 Using where
207
4 SUBQUERY t3 ALL NULL NULL NULL NULL # 100.00 Using where
208
3 SUBQUERY t3 ALL NULL NULL NULL NULL # 100.00 Using where
210
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2` from `test`.`t2` where (<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` AS `c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` AS `c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key)))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key))))
212
where (a1, a2) in (select b1, b2 from t2
213
where b2 in (select c2 from t3 where c2 LIKE '%02') or
214
b2 in (select c2 from t3 where c2 LIKE '%03')) and
215
(a1, a2) in (select c1, c2 from t3
216
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
221
where (a1, a2) in (select b1, b2 from t2
222
where b2 in (select c2 from t3 t3a where c1 = a1) or
223
b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
224
(a1, a2) in (select c1, c2 from t3 t3c
225
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
226
id select_type table type possible_keys key key_len ref rows filtered Extra
227
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
228
5 SUBQUERY t3c ALL NULL NULL NULL NULL # 100.00 Using where
229
6 SUBQUERY t2i ALL it2i2 NULL NULL NULL # 100.00 Using where
230
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00 Using where
231
4 SUBQUERY t3b ALL NULL NULL NULL NULL # 100.00 Using where
232
3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL # 100.00 Using where
234
Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1
235
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2` from `test`.`t2` where ((<in_optimizer>(`test`.`t2`.`b2`,<exists>(select 1 AS `Not_used` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`)))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` AS `c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key)))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3c`.`c1` AS `c1`,`test`.`t3c`.`c2` AS `c2` from `test`.`t3` `t3c` where <in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),(`test`.`t3c`.`c1`,`test`.`t3c`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3c`.`c1` in <temporary table> on distinct_key))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key))))
237
where (a1, a2) in (select b1, b2 from t2
238
where b2 in (select c2 from t3 t3a where c1 = a1) or
239
b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
240
(a1, a2) in (select c1, c2 from t3 t3c
241
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
247
where (a1, a2) in (select b1, b2 from t2
248
where b2 in (select c2 from t3 where c2 LIKE '%02') or
249
b2 in (select c2 from t3 where c2 LIKE '%03')
251
(a1, a2) in (select c1, c2 from t3
252
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')))
255
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
256
(a1, a2) in (select c1, c2 from t3i
257
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
258
id select_type table type possible_keys key key_len ref rows filtered Extra
259
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
260
5 SUBQUERY t3 ALL NULL NULL NULL NULL # 100.00 Using where
261
6 SUBQUERY t2i ALL it2i2 NULL NULL NULL # 100.00 Using where
262
2 SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00 Using where; Using temporary; Using filesort
263
4 SUBQUERY t3 ALL NULL NULL NULL NULL # 100.00 Using where
264
3 SUBQUERY t3 ALL NULL NULL NULL NULL # 100.00 Using where
265
7 UNION t1i index NULL it1i3 70 NULL # 100.00 Using where; Using index
266
9 SUBQUERY t3i index NULL it3i3 70 NULL # 100.00 Using where; Using index
267
10 SUBQUERY t2i ALL it2i2 NULL NULL NULL # 100.00 Using where
268
8 SUBQUERY t2i ALL it2i1,it2i3 NULL NULL NULL # 100.00 Using where
269
NULL UNION RESULT <union1,7> ALL NULL NULL NULL NULL # NULL
271
Note 1003 (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2` from `test`.`t2` where (<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` AS `c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` AS `c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key)))) group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key))))) union (select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key))) and <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1` AS `c1`,`test`.`t3i`.`c2` AS `c2` from `test`.`t3i` where <in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key)))))
273
where (a1, a2) in (select b1, b2 from t2
274
where b2 in (select c2 from t3 where c2 LIKE '%02') or
275
b2 in (select c2 from t3 where c2 LIKE '%03')
277
(a1, a2) in (select c1, c2 from t3
278
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')))
281
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
282
(a1, a2) in (select c1, c2 from t3i
283
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')));
289
where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
290
(a1, a2) in (select c1, c2 from t3
291
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
292
id select_type table type possible_keys key key_len ref rows filtered Extra
293
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
294
4 SUBQUERY t3 ALL NULL NULL NULL NULL # 100.00 Using where
295
5 SUBQUERY t2i ALL it2i2 NULL NULL NULL # 100.00 Using where
296
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # 100.00 Using where
297
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL # 100.00 Using where
298
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL # NULL
300
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key))))
302
where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
303
(a1, a2) in (select c1, c2 from t3
304
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
310
where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
311
(c1, c2) in (select c1, c2 from t3
312
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
314
id select_type table type possible_keys key key_len ref rows filtered Extra
315
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
316
1 PRIMARY t3 ALL NULL NULL NULL NULL # 100.00 Using where; Using join buffer
317
4 SUBQUERY t3 ALL NULL NULL NULL NULL # 100.00 Using where
318
5 SUBQUERY t2i ALL it2i2 NULL NULL NULL # 100.00 Using where
319
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # 100.00 Using where
320
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL # 100.00 Using where
321
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL # NULL
323
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1` AS `b1`,`test`.`t2i`.`b2` AS `b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key))) ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key))))
325
where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
326
(c1, c2) in (select c1, c2 from t3
327
where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
330
1 - 01 2 - 01 1 - 01 2 - 01
331
1 - 02 2 - 02 1 - 02 2 - 02
332
/*********************************************************************
333
* Negative tests, where materialization should not be applied.
334
**********************************************************************/
335
# UNION in a subquery
338
where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
339
id select_type table type possible_keys key key_len ref rows filtered Extra
340
1 PRIMARY t3 ALL NULL NULL NULL NULL # 100.00 Using where
341
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # 100.00 Using where
342
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL # 100.00 Using where
343
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL # NULL
345
Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <in_optimizer>(`test`.`t3`.`c1`,<exists>(select 1 AS `Not_used` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select 1 AS `Not_used` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`))))
347
where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9');
354
where (a1, a2) in (select b1, b2 from t2
355
where b2 in (select c2 from t3 t3a where c1 = a1) or
356
b2 in (select c2 from t3 t3b where c2 LIKE '%03')) and
357
(a1, a2) in (select c1, c2 from t3 t3c
358
where (c1, c2) in (select b1, b2 from t2i where b2 > '0' or b2 = a2));
359
id select_type table type possible_keys key key_len ref rows filtered Extra
360
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
361
5 DEPENDENT SUBQUERY t3c ALL NULL NULL NULL NULL # 100.00 Using where
362
6 DEPENDENT SUBQUERY t2i index_subquery it2i1,it2i2,it2i3 it2i1 35 func # 100.00 Using where
363
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL # 100.00 Using where
364
4 SUBQUERY t3b ALL NULL NULL NULL NULL # 100.00 Using where
365
3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL # 100.00 Using where
367
Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1
368
Note 1276 Field or reference 'test.t1.a2' of SELECT #6 was resolved in SELECT #1
369
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1` AS `b1`,`test`.`t2`.`b2` AS `b2` from `test`.`t2` where ((<in_optimizer>(`test`.`t2`.`b2`,<exists>(select 1 AS `Not_used` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`)))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` AS `c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key)))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t3c`.`c1` AS `c1`,`test`.`t3c`.`c2` AS `c2` from `test`.`t3` `t3c` where (<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),<exists>(<index_lookup>(<cache>(`test`.`t3c`.`c1`) in t2i on it2i1 where (((`test`.`t2i`.`b2` > '0') or (`test`.`t2i`.`b2` = `test`.`t1`.`a2`)) and (<cache>(`test`.`t3c`.`c1`) = `test`.`t2i`.`b1`) and (<cache>(`test`.`t3c`.`c2`) = `test`.`t2i`.`b2`))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t3c`.`c1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t3c`.`c2`)))))
370
DROP TABLE t1i, t2i, t3i;
372
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
373
id select_type table type possible_keys key key_len ref rows filtered Extra
374
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using where
375
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL # NULL No tables used
377
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01' AS `1 - 01`,'2 - 01' AS `2 - 01` having ((<cache>(`test`.`t1`.`a1`) = '1 - 01') and (<cache>(`test`.`t1`.`a2`) = '2 - 01'))))
378
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
381
/******************************************************************************
382
* Subqueries in other uncovered clauses.
383
******************************************************************************/
385
select ((a1,a2) IN (select * from t2 where b2 > '0')) IS NULL from t1;
386
((a1,a2) IN (select * from t2 where b2 > '0')) IS NULL
390
/* GROUP BY clause */
391
create temporary table columns (col int key) ENGINE=MyISAM;
392
insert into columns values (1), (2);
394
select * from t1 group by (select col from columns limit 1);
395
id select_type table type possible_keys key key_len ref rows filtered Extra
396
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00
397
2 SUBQUERY columns index NULL PRIMARY 4 NULL # 100.00 Using index
399
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` group by (select `test`.`columns`.`col` AS `col` from `test`.`columns` limit 1)
400
select * from t1 group by (select col from columns limit 1);
404
select * from t1 group by (a1 in (select col from columns));
405
id select_type table type possible_keys key key_len ref rows filtered Extra
406
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00 Using temporary; Using filesort
407
2 DEPENDENT SUBQUERY columns unique_subquery PRIMARY PRIMARY 4 func # 100.00 Using index; Using where; Full scan on NULL key
409
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` group by <in_optimizer>(`test`.`t1`.`a1`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`a1`) in columns on PRIMARY where trigcond((<cache>(`test`.`t1`.`a1`) = `test`.`columns`.`col`)))))
410
select * from t1 group by (a1 in (select col from columns));
413
/* ORDER BY clause */
415
select * from t1 order by (select col from columns limit 1);
416
id select_type table type possible_keys key key_len ref rows filtered Extra
417
1 PRIMARY t1 ALL NULL NULL NULL NULL # 100.00
418
2 SUBQUERY columns index NULL PRIMARY 4 NULL # 100.00 Using index
420
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` order by (select `test`.`columns`.`col` AS `col` from `test`.`columns` limit 1)
421
select * from t1 order by (select col from columns limit 1);
427
/******************************************************************************
428
* Column types/sizes that affect materialization.
429
******************************************************************************/
431
Test that BLOBs are not materialized (except when arguments of some functions).
433
# force materialization to be always considered
436
set @suffix_len = @blob_len - @prefix_len;
437
create temporary table t1_16 (a1 blob, a2 blob) ENGINE=MyISAM;
438
create temporary table t2_16 (b1 blob, b2 blob) ENGINE=MyISAM;
439
create temporary table t3_16 (c1 blob, c2 blob) ENGINE=MyISAM;
440
insert into t1_16 values
441
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
442
insert into t1_16 values
443
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
444
insert into t1_16 values
445
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
446
insert into t2_16 values
447
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
448
insert into t2_16 values
449
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
450
insert into t2_16 values
451
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
452
insert into t3_16 values
453
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
454
insert into t3_16 values
455
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
456
insert into t3_16 values
457
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
458
insert into t3_16 values
459
(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
460
explain extended select left(a1,7), left(a2,7)
462
where a1 in (select b1 from t2_16 where b1 > '0');
463
id select_type table type possible_keys key key_len ref rows filtered Extra
464
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
465
2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
467
Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in (select 1 AS `Not_used` from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`))))
468
select left(a1,7), left(a2,7)
470
where a1 in (select b1 from t2_16 where b1 > '0');
471
left(a1,7) left(a2,7)
474
explain extended select left(a1,7), left(a2,7)
476
where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
477
id select_type table type possible_keys key key_len ref rows filtered Extra
478
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
479
2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
481
Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`) in (select `test`.`t2_16`.`b1` AS `b1`,`test`.`t2_16`.`b2` AS `b2` from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))))
482
select left(a1,7), left(a2,7)
484
where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0');
485
left(a1,7) left(a2,7)
488
explain extended select left(a1,7), left(a2,7)
490
where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
491
id select_type table type possible_keys key key_len ref rows filtered Extra
492
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
493
2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
495
Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select substr(`test`.`t2_16`.`b1`,1,16) AS `substring(b1,1,16)` from `test`.`t2_16` where (`test`.`t2_16`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key)))
496
select left(a1,7), left(a2,7)
498
where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0');
499
left(a1,7) left(a2,7)
502
explain extended select left(a1,7), left(a2,7)
504
where a1 in (select group_concat(b1) from t2_16 group by b2);
505
id select_type table type possible_keys key key_len ref rows filtered Extra
506
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
507
2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort
509
Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in (select group_concat(`test`.`t2_16`.`b1` separator ',') AS `group_concat(b1)` from `test`.`t2_16` group by `test`.`t2_16`.`b2` having (<cache>(`test`.`t1_16`.`a1`) = <ref_null_helper>(group_concat(`test`.`t2_16`.`b1` separator ',')))))
510
select left(a1,7), left(a2,7)
512
where a1 in (select group_concat(b1) from t2_16 group by b2);
513
left(a1,7) left(a2,7)
516
set @@group_concat_max_len = 256;
517
explain extended select left(a1,7), left(a2,7)
519
where a1 in (select group_concat(b1) from t2_16 group by b2);
520
id select_type table type possible_keys key key_len ref rows filtered Extra
521
1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
522
2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort
524
Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select group_concat(`test`.`t2_16`.`b1` separator ',') AS `group_concat(b1)` from `test`.`t2_16` group by `test`.`t2_16`.`b2` ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key)))
525
select left(a1,7), left(a2,7)
527
where a1 in (select group_concat(b1) from t2_16 group by b2);
528
left(a1,7) left(a2,7)
533
where concat(a1,'x') IN
534
(select left(a1,8) from t1_16
536
(select t2_16.b1, t2_16.b2 from t2_16, t2
537
where t2.b2 = substring(t2_16.b2,1,6) and
538
t2.b1 IN (select c1 from t3 where c2 > '0')));
539
id select_type table type possible_keys key key_len ref rows filtered Extra
540
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
541
2 SUBQUERY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where
542
3 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where
543
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer
544
4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
546
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>(concat(`test`.`t1`.`a1`,'x'),concat(`test`.`t1`.`a1`,'x') in ( <materialize> (select left(`test`.`t1_16`.`a1`,8) AS `left(a1,8)` from `test`.`t1_16` where <in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`) in (select `test`.`t2_16`.`b1` AS `b1`,`test`.`t2_16`.`b2` AS `b2` from `test`.`t2_16` join `test`.`t2` where ((`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and <in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (select `test`.`t3`.`c1` AS `c1` from `test`.`t3` where (`test`.`t3`.`c2` > '0') ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on distinct_key))) and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`)))) ), <primary_index_lookup>(concat(`test`.`t1`.`a1`,'x') in <temporary table> on distinct_key)))
547
drop table t1_16, t2_16, t3_16;
549
set @suffix_len = @blob_len - @prefix_len;
550
create temporary table t1_512 (a1 blob, a2 blob) ENGINE=MyISAM;
551
create temporary table t2_512 (b1 blob, b2 blob) ENGINE=MyISAM;
552
create temporary table t3_512 (c1 blob, c2 blob) ENGINE=MyISAM;
553
insert into t1_512 values
554
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
555
insert into t1_512 values
556
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
557
insert into t1_512 values
558
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
559
insert into t2_512 values
560
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
561
insert into t2_512 values
562
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
563
insert into t2_512 values
564
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
565
insert into t3_512 values
566
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
567
insert into t3_512 values
568
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
569
insert into t3_512 values
570
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
571
insert into t3_512 values
572
(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
573
explain extended select left(a1,7), left(a2,7)
575
where a1 in (select b1 from t2_512 where b1 > '0');
576
id select_type table type possible_keys key key_len ref rows filtered Extra
577
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
578
2 DEPENDENT SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where
580
Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in (select 1 AS `Not_used` from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`))))
581
select left(a1,7), left(a2,7)
583
where a1 in (select b1 from t2_512 where b1 > '0');
584
left(a1,7) left(a2,7)
587
explain extended select left(a1,7), left(a2,7)
589
where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
590
id select_type table type possible_keys key key_len ref rows filtered Extra
591
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
592
2 DEPENDENT SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where
594
Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>((`test`.`t1_512`.`a1`,`test`.`t1_512`.`a2`),(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a2`) in (select `test`.`t2_512`.`b1` AS `b1`,`test`.`t2_512`.`b2` AS `b2` from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`) and (<cache>(`test`.`t1_512`.`a2`) = `test`.`t2_512`.`b2`))))
595
select left(a1,7), left(a2,7)
597
where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0');
598
left(a1,7) left(a2,7)
601
explain extended select left(a1,7), left(a2,7)
603
where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
604
id select_type table type possible_keys key key_len ref rows filtered Extra
605
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
606
2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where
608
Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select substr(`test`.`t2_512`.`b1`,1,512) AS `substring(b1,1,512)` from `test`.`t2_512` where (`test`.`t2_512`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key)))
609
select left(a1,7), left(a2,7)
611
where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
612
left(a1,7) left(a2,7)
615
explain extended select left(a1,7), left(a2,7)
617
where a1 in (select group_concat(b1) from t2_512 group by b2);
618
id select_type table type possible_keys key key_len ref rows filtered Extra
619
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
620
2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort
622
Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') AS `group_concat(b1)` from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key)))
623
select left(a1,7), left(a2,7)
625
where a1 in (select group_concat(b1) from t2_512 group by b2);
626
left(a1,7) left(a2,7)
629
set @@group_concat_max_len = 256;
630
explain extended select left(a1,7), left(a2,7)
632
where a1 in (select group_concat(b1) from t2_512 group by b2);
633
id select_type table type possible_keys key key_len ref rows filtered Extra
634
1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where
635
2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort
637
Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') AS `group_concat(b1)` from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key)))
638
select left(a1,7), left(a2,7)
640
where a1 in (select group_concat(b1) from t2_512 group by b2);
641
left(a1,7) left(a2,7)
644
drop table t1_512, t2_512, t3_512;
645
set @blob_len = 1024;
646
set @suffix_len = @blob_len - @prefix_len;
647
create temporary table t1_1024 (a1 blob, a2 blob) ENGINE=MyISAM;
648
create temporary table t2_1024 (b1 blob, b2 blob) ENGINE=MyISAM;
649
create temporary table t3_1024 (c1 blob, c2 blob) ENGINE=MyISAM;
650
insert into t1_1024 values
651
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
652
insert into t1_1024 values
653
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
654
insert into t1_1024 values
655
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
656
insert into t2_1024 values
657
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
658
insert into t2_1024 values
659
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
660
insert into t2_1024 values
661
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
662
insert into t3_1024 values
663
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
664
insert into t3_1024 values
665
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
666
insert into t3_1024 values
667
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
668
insert into t3_1024 values
669
(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
670
explain extended select left(a1,7), left(a2,7)
672
where a1 in (select b1 from t2_1024 where b1 > '0');
673
id select_type table type possible_keys key key_len ref rows filtered Extra
674
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
675
2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
677
Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in (select 1 AS `Not_used` from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`))))
678
select left(a1,7), left(a2,7)
680
where a1 in (select b1 from t2_1024 where b1 > '0');
681
left(a1,7) left(a2,7)
684
explain extended select left(a1,7), left(a2,7)
686
where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
687
id select_type table type possible_keys key key_len ref rows filtered Extra
688
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
689
2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
691
Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>((`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a2`),(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a2`) in (select `test`.`t2_1024`.`b1` AS `b1`,`test`.`t2_1024`.`b2` AS `b2` from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`) and (<cache>(`test`.`t1_1024`.`a2`) = `test`.`t2_1024`.`b2`))))
692
select left(a1,7), left(a2,7)
694
where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0');
695
left(a1,7) left(a2,7)
698
explain extended select left(a1,7), left(a2,7)
700
where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
701
id select_type table type possible_keys key key_len ref rows filtered Extra
702
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
703
2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
705
Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in (select 1 AS `Not_used` from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = substr(`test`.`t2_1024`.`b1`,1,1024)))))
706
select left(a1,7), left(a2,7)
708
where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
709
left(a1,7) left(a2,7)
712
explain extended select left(a1,7), left(a2,7)
714
where a1 in (select group_concat(b1) from t2_1024 group by b2);
715
id select_type table type possible_keys key key_len ref rows filtered Extra
716
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
717
2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort
719
Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') AS `group_concat(b1)` from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key)))
720
select left(a1,7), left(a2,7)
722
where a1 in (select group_concat(b1) from t2_1024 group by b2);
723
left(a1,7) left(a2,7)
726
set @@group_concat_max_len = 256;
727
explain extended select left(a1,7), left(a2,7)
729
where a1 in (select group_concat(b1) from t2_1024 group by b2);
730
id select_type table type possible_keys key key_len ref rows filtered Extra
731
1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where
732
2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort
734
Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') AS `group_concat(b1)` from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key)))
735
select left(a1,7), left(a2,7)
737
where a1 in (select group_concat(b1) from t2_1024 group by b2);
738
left(a1,7) left(a2,7)
741
drop table t1_1024, t2_1024, t3_1024;
742
set @blob_len = 1025;
743
set @suffix_len = @blob_len - @prefix_len;
744
create temporary table t1_1025 (a1 blob, a2 blob) ENGINE=MyISAM;
745
create temporary table t2_1025 (b1 blob, b2 blob) ENGINE=MyISAM;
746
create temporary table t3_1025 (c1 blob, c2 blob) ENGINE=MyISAM;
747
insert into t1_1025 values
748
(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
749
insert into t1_1025 values
750
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
751
insert into t1_1025 values
752
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
753
insert into t2_1025 values
754
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
755
insert into t2_1025 values
756
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
757
insert into t2_1025 values
758
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
759
insert into t3_1025 values
760
(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
761
insert into t3_1025 values
762
(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
763
insert into t3_1025 values
764
(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
765
insert into t3_1025 values
766
(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
767
explain extended select left(a1,7), left(a2,7)
769
where a1 in (select b1 from t2_1025 where b1 > '0');
770
id select_type table type possible_keys key key_len ref rows filtered Extra
771
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
772
2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
774
Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in (select 1 AS `Not_used` from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`))))
775
select left(a1,7), left(a2,7)
777
where a1 in (select b1 from t2_1025 where b1 > '0');
778
left(a1,7) left(a2,7)
781
explain extended select left(a1,7), left(a2,7)
783
where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
784
id select_type table type possible_keys key key_len ref rows filtered Extra
785
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
786
2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
788
Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>((`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a2`),(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a2`) in (select `test`.`t2_1025`.`b1` AS `b1`,`test`.`t2_1025`.`b2` AS `b2` from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`) and (<cache>(`test`.`t1_1025`.`a2`) = `test`.`t2_1025`.`b2`))))
789
select left(a1,7), left(a2,7)
791
where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0');
792
left(a1,7) left(a2,7)
795
explain extended select left(a1,7), left(a2,7)
797
where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
798
id select_type table type possible_keys key key_len ref rows filtered Extra
799
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
800
2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
802
Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in (select 1 AS `Not_used` from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = substr(`test`.`t2_1025`.`b1`,1,1025)))))
803
select left(a1,7), left(a2,7)
805
where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
806
left(a1,7) left(a2,7)
809
explain extended select left(a1,7), left(a2,7)
811
where a1 in (select group_concat(b1) from t2_1025 group by b2);
812
id select_type table type possible_keys key key_len ref rows filtered Extra
813
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
814
2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort
816
Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') AS `group_concat(b1)` from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key)))
817
select left(a1,7), left(a2,7)
819
where a1 in (select group_concat(b1) from t2_1025 group by b2);
820
left(a1,7) left(a2,7)
823
set @@group_concat_max_len = 256;
824
explain extended select left(a1,7), left(a2,7)
826
where a1 in (select group_concat(b1) from t2_1025 group by b2);
827
id select_type table type possible_keys key key_len ref rows filtered Extra
828
1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where
829
2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort
831
Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') AS `group_concat(b1)` from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key)))
832
select left(a1,7), left(a2,7)
834
where a1 in (select group_concat(b1) from t2_1025 group by b2);
835
left(a1,7) left(a2,7)
838
drop table t1_1025, t2_1025, t3_1025;
839
drop table t1, t2, t3;
840
/******************************************************************************
841
* Test the cache of the left operand of IN.
842
******************************************************************************/
843
# Test that default values of Cached_item are not used for comparison
844
create temporary table t1 (s1 int) ENGINE=MyISAM;
845
create temporary table t2 (s2 int) ENGINE=MyISAM;
846
insert into t1 values (5),(1),(0);
847
insert into t2 values (0), (1);
848
select s2 from t2 where s2 in (select s1 from t1);
853
create temporary table t1 (a int not null, b int not null) ENGINE=MyISAM;
854
create temporary table t2 (c int not null, d int not null) ENGINE=MyISAM;
855
create temporary table t3 (e int not null) ENGINE=MyISAM;
856
insert into t1 values (1,10);
857
insert into t1 values (1,20);
858
insert into t1 values (2,10);
859
insert into t1 values (2,20);
860
insert into t1 values (2,30);
861
insert into t1 values (3,20);
862
insert into t1 values (4,40);
863
insert into t2 values (2,10);
864
insert into t2 values (2,20);
865
insert into t2 values (2,40);
866
insert into t2 values (3,20);
867
insert into t2 values (4,10);
868
insert into t2 values (5,10);
869
insert into t3 values (10);
870
insert into t3 values (10);
871
insert into t3 values (20);
872
insert into t3 values (30);
874
select a from t1 where a in (select c from t2 where d >= 20);
875
id select_type table type possible_keys key key_len ref rows filtered Extra
876
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 Using where
877
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
879
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` AS `c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key)))
880
select a from t1 where a in (select c from t2 where d >= 20);
886
create index it1a on t1(a);
888
select a from t1 where a in (select c from t2 where d >= 20);
889
id select_type table type possible_keys key key_len ref rows filtered Extra
890
1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using where; Using index
891
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
893
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` AS `c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key)))
894
select a from t1 where a in (select c from t2 where d >= 20);
900
insert into t2 values (1,10);
902
select a from t1 where a in (select c from t2 where d >= 20);
903
id select_type table type possible_keys key key_len ref rows filtered Extra
904
1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using where; Using index
905
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
907
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` AS `c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key)))
908
select a from t1 where a in (select c from t2 where d >= 20);
915
select a from t1 group by a having a in (select c from t2 where d >= 20);
916
id select_type table type possible_keys key key_len ref rows filtered Extra
917
1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
918
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
920
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` AS `c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key)))
921
select a from t1 group by a having a in (select c from t2 where d >= 20);
925
create index iab on t1(a, b);
927
select a from t1 group by a having a in (select c from t2 where d >= 20);
928
id select_type table type possible_keys key key_len ref rows filtered Extra
929
1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
930
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
932
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` AS `c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key)))
933
select a from t1 group by a having a in (select c from t2 where d >= 20);
938
select a from t1 group by a
939
having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
940
id select_type table type possible_keys key key_len ref rows filtered Extra
941
1 PRIMARY t1 index NULL iab 8 NULL 7 100.00 Using index
942
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
943
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
945
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
946
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t2` where (<nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` AS `e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`))))
947
select a from t1 group by a
948
having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
954
where a in (select c from t2 where d >= some(select e from t3 where b=e));
955
id select_type table type possible_keys key key_len ref rows filtered Extra
956
1 PRIMARY t1 index NULL iab 8 NULL 7 100.00 Using where; Using index
957
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
958
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
960
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
961
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t2` where (<nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 AS `Not_used` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`))))
963
where a in (select c from t2 where d >= some(select e from t3 where b=e));
970
drop table t1, t2, t3;