76
76
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
77
77
explain select * from t1 where a is null and b = 2;
78
78
id select_type table type possible_keys key key_len ref rows Extra
79
1 SIMPLE t1 ref a,b a 5 const 3 Using where
79
1 SIMPLE t1 ref a,b a 5 const X Using where
80
80
explain select * from t1 where a is null and b = 2 and c=0;
81
81
id select_type table type possible_keys key key_len ref rows Extra
82
1 SIMPLE t1 ref a,b a 5 const 3 Using where
82
1 SIMPLE t1 ref a,b a 5 const X Using where
83
83
explain select * from t1 where a is null and b = 7 and c=0;
84
84
id select_type table type possible_keys key key_len ref rows Extra
85
1 SIMPLE t1 ref a,b a 5 const 3 Using where
85
1 SIMPLE t1 ref a,b a 5 const X Using where
86
86
explain select * from t1 where a=2 and b = 2;
87
87
id select_type table type possible_keys key key_len ref rows Extra
88
1 SIMPLE t1 ref a,b a 5 const 1 Using where
88
1 SIMPLE t1 ref a,b a 5 const X Using where
89
89
explain select * from t1 where a<=>b limit 2;
90
90
id select_type table type possible_keys key key_len ref rows Extra
91
1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using where
91
1 SIMPLE t1 ALL NULL NULL NULL NULL X Using where
92
92
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 and c=0 limit 3;
93
93
id select_type table type possible_keys key key_len ref rows Extra
94
1 SIMPLE t1 range a,b a 5 NULL 5 Using where
94
1 SIMPLE t1 range a,b a 5 NULL X Using where
95
95
explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
96
96
id select_type table type possible_keys key key_len ref rows Extra
97
1 SIMPLE t1 ref_or_null a,b a 5 const 4 Using where
97
1 SIMPLE t1 ref_or_null a,b a 5 const X Using where
98
98
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
99
99
id select_type table type possible_keys key key_len ref rows Extra
100
1 SIMPLE t1 ref a,b a 5 const 3 Using where
100
1 SIMPLE t1 ref a,b a 5 const X Using where
101
101
explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
102
102
id select_type table type possible_keys key key_len ref rows Extra
103
1 SIMPLE t1 ref a,b a 5 const 3 Using where
103
1 SIMPLE t1 ref a,b a 5 const X Using where
104
104
explain select * from t1 where a > 1 and a < 3 limit 1;
105
105
id select_type table type possible_keys key key_len ref rows Extra
106
1 SIMPLE t1 range a a 5 NULL 1 Using where
106
1 SIMPLE t1 range a a 5 NULL X Using where
107
107
explain select * from t1 where a is null and b=7 or a > 1 and a < 3 limit 1;
108
108
id select_type table type possible_keys key key_len ref rows Extra
109
1 SIMPLE t1 range a,b a 5 NULL 4 Using where
109
1 SIMPLE t1 range a,b a 5 NULL X Using where
110
110
explain select * from t1 where a > 8 and a < 9;
111
111
id select_type table type possible_keys key key_len ref rows Extra
112
1 SIMPLE t1 range a a 5 NULL 1 Using where
112
1 SIMPLE t1 range a a 5 NULL X Using where
113
113
explain select * from t1 where b like "6%";
114
114
id select_type table type possible_keys key key_len ref rows Extra
115
1 SIMPLE t1 range b b 12 NULL 1 Using where
115
1 SIMPLE t1 range b b 12 NULL X Using where
116
116
select * from t1 where a is null;
172
172
insert into t2 values (7),(8);
173
173
explain select * from t2 straight_join t1 where t1.a=t2.a and b is null;
174
174
id select_type table type possible_keys key key_len ref rows Extra
175
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
176
1 SIMPLE t1 ref a,b b 5 const 1 Using where
175
1 SIMPLE t2 ALL NULL NULL NULL NULL X
176
1 SIMPLE t1 ref a,b b 5 const X Using where
177
177
drop index b on t1;
178
178
explain select * from t2,t1 where t1.a=t2.a and b is null;
179
179
id select_type table type possible_keys key key_len ref rows Extra
180
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
181
1 SIMPLE t1 ref a a 10 test.t2.a,const 2 Using where; Using index
180
1 SIMPLE t2 ALL NULL NULL NULL NULL X
181
1 SIMPLE t1 ref a a 10 test.t2.a,const X Using where; Using index
182
182
select * from t2,t1 where t1.a=t2.a and b is null;
186
186
explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
187
187
id select_type table type possible_keys key key_len ref rows Extra
188
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
189
1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 2 Using index
188
1 SIMPLE t2 ALL NULL NULL NULL NULL X
189
1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const X Using index
190
190
select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
195
195
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
196
196
id select_type table type possible_keys key key_len ref rows Extra
197
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
198
1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 2 Using index
197
1 SIMPLE t2 ALL NULL NULL NULL NULL X
198
1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const X Using index
199
199
select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
202
202
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
203
203
id select_type table type possible_keys key key_len ref rows Extra
204
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
205
1 SIMPLE t1 ref_or_null a a 5 test.t2.a 2 Using where; Using index
204
1 SIMPLE t2 ALL NULL NULL NULL NULL X
205
1 SIMPLE t1 ref_or_null a a 5 test.t2.a X Using where; Using index
206
206
select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
212
212
delete from t1 where a=8;
213
213
explain select * from t2,t1 where t1.a=t2.a or t1.a is null;
214
214
id select_type table type possible_keys key key_len ref rows Extra
215
1 SIMPLE t1 system a NULL NULL NULL 1
216
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
215
1 SIMPLE t1 system a NULL NULL NULL X
216
1 SIMPLE t2 ALL NULL NULL NULL NULL X Using where
217
217
explain select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
218
218
id select_type table type possible_keys key key_len ref rows Extra
219
1 SIMPLE t1 system a NULL NULL NULL 1
220
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
219
1 SIMPLE t1 system a NULL NULL NULL X
220
1 SIMPLE t2 ALL NULL NULL NULL NULL X Using where
221
221
select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);