|
| 1 | +drop table if exists t1; |
| 2 | +create table t1 (a int, key (a)); |
| 3 | +insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
| 4 | +(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); |
| 5 | +explain select * from t1 where not(not(a)); |
| 6 | +id select_type table type possible_keys key key_len ref rows Extra |
| 7 | +1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index |
| 8 | +select * from t1 where not(not(a)); |
| 9 | +a |
| 10 | +1 |
| 11 | +2 |
| 12 | +3 |
| 13 | +4 |
| 14 | +5 |
| 15 | +6 |
| 16 | +7 |
| 17 | +8 |
| 18 | +9 |
| 19 | +10 |
| 20 | +11 |
| 21 | +12 |
| 22 | +13 |
| 23 | +14 |
| 24 | +15 |
| 25 | +16 |
| 26 | +17 |
| 27 | +18 |
| 28 | +19 |
| 29 | +explain select * from t1 where not(not(not(a > 10))); |
| 30 | +id select_type table type possible_keys key key_len ref rows Extra |
| 31 | +1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index |
| 32 | +select * from t1 where not(not(not(a > 10))); |
| 33 | +a |
| 34 | +0 |
| 35 | +1 |
| 36 | +2 |
| 37 | +3 |
| 38 | +4 |
| 39 | +5 |
| 40 | +6 |
| 41 | +7 |
| 42 | +8 |
| 43 | +9 |
| 44 | +10 |
| 45 | +explain select * from t1 where not(not(not(a < 5) and not(a > 10))); |
| 46 | +id select_type table type possible_keys key key_len ref rows Extra |
| 47 | +1 SIMPLE t1 range a a 5 NULL 5 Using where; Using index |
| 48 | +select * from t1 where not(not(not(a < 5) and not(a > 10))); |
| 49 | +a |
| 50 | +5 |
| 51 | +6 |
| 52 | +7 |
| 53 | +8 |
| 54 | +9 |
| 55 | +10 |
| 56 | +explain select * from t1 where not(a = 10); |
| 57 | +id select_type table type possible_keys key key_len ref rows Extra |
| 58 | +1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index |
| 59 | +select * from t1 where not(a = 10); |
| 60 | +a |
| 61 | +0 |
| 62 | +1 |
| 63 | +2 |
| 64 | +3 |
| 65 | +4 |
| 66 | +5 |
| 67 | +6 |
| 68 | +7 |
| 69 | +8 |
| 70 | +9 |
| 71 | +11 |
| 72 | +12 |
| 73 | +13 |
| 74 | +14 |
| 75 | +15 |
| 76 | +16 |
| 77 | +17 |
| 78 | +18 |
| 79 | +19 |
| 80 | +explain select * from t1 where not(a != 10); |
| 81 | +id select_type table type possible_keys key key_len ref rows Extra |
| 82 | +1 SIMPLE t1 ref a a 5 const 1 Using where; Using index |
| 83 | +select * from t1 where not(a != 1); |
| 84 | +a |
| 85 | +1 |
| 86 | +explain select * from t1 where not(a < 10); |
| 87 | +id select_type table type possible_keys key key_len ref rows Extra |
| 88 | +1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index |
| 89 | +select * from t1 where not(a < 10); |
| 90 | +a |
| 91 | +10 |
| 92 | +11 |
| 93 | +12 |
| 94 | +13 |
| 95 | +14 |
| 96 | +15 |
| 97 | +16 |
| 98 | +17 |
| 99 | +18 |
| 100 | +19 |
| 101 | +explain select * from t1 where not(a >= 10); |
| 102 | +id select_type table type possible_keys key key_len ref rows Extra |
| 103 | +1 SIMPLE t1 range a a 5 NULL 9 Using where; Using index |
| 104 | +select * from t1 where not(a >= 10); |
| 105 | +a |
| 106 | +0 |
| 107 | +1 |
| 108 | +2 |
| 109 | +3 |
| 110 | +4 |
| 111 | +5 |
| 112 | +6 |
| 113 | +7 |
| 114 | +8 |
| 115 | +9 |
| 116 | +explain select * from t1 where not(a > 10); |
| 117 | +id select_type table type possible_keys key key_len ref rows Extra |
| 118 | +1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index |
| 119 | +select * from t1 where not(a > 10); |
| 120 | +a |
| 121 | +0 |
| 122 | +1 |
| 123 | +2 |
| 124 | +3 |
| 125 | +4 |
| 126 | +5 |
| 127 | +6 |
| 128 | +7 |
| 129 | +8 |
| 130 | +9 |
| 131 | +10 |
| 132 | +explain select * from t1 where not(a <= 10); |
| 133 | +id select_type table type possible_keys key key_len ref rows Extra |
| 134 | +1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index |
| 135 | +select * from t1 where not(a <= 10); |
| 136 | +a |
| 137 | +11 |
| 138 | +12 |
| 139 | +13 |
| 140 | +14 |
| 141 | +15 |
| 142 | +16 |
| 143 | +17 |
| 144 | +18 |
| 145 | +19 |
| 146 | +explain select * from t1 where not(a is null); |
| 147 | +id select_type table type possible_keys key key_len ref rows Extra |
| 148 | +1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index |
| 149 | +select * from t1 where not(a is null); |
| 150 | +a |
| 151 | +0 |
| 152 | +1 |
| 153 | +2 |
| 154 | +3 |
| 155 | +4 |
| 156 | +5 |
| 157 | +6 |
| 158 | +7 |
| 159 | +8 |
| 160 | +9 |
| 161 | +10 |
| 162 | +11 |
| 163 | +12 |
| 164 | +13 |
| 165 | +14 |
| 166 | +15 |
| 167 | +16 |
| 168 | +17 |
| 169 | +18 |
| 170 | +19 |
| 171 | +explain select * from t1 where not(a is not null); |
| 172 | +id select_type table type possible_keys key key_len ref rows Extra |
| 173 | +1 SIMPLE t1 ref a a 5 const 1 Using where; Using index |
| 174 | +select * from t1 where not(a is not null); |
| 175 | +a |
| 176 | +NULL |
| 177 | +explain select * from t1 where not(a < 5 or a > 15); |
| 178 | +id select_type table type possible_keys key key_len ref rows Extra |
| 179 | +1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index |
| 180 | +select * from t1 where not(a < 5 or a > 15); |
| 181 | +a |
| 182 | +5 |
| 183 | +6 |
| 184 | +7 |
| 185 | +8 |
| 186 | +9 |
| 187 | +10 |
| 188 | +11 |
| 189 | +12 |
| 190 | +13 |
| 191 | +14 |
| 192 | +15 |
| 193 | +explain select * from t1 where not(a < 15 and a > 5); |
| 194 | +id select_type table type possible_keys key key_len ref rows Extra |
| 195 | +1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index |
| 196 | +select * from t1 where not(a < 15 and a > 5); |
| 197 | +a |
| 198 | +0 |
| 199 | +1 |
| 200 | +2 |
| 201 | +3 |
| 202 | +4 |
| 203 | +5 |
| 204 | +15 |
| 205 | +16 |
| 206 | +17 |
| 207 | +18 |
| 208 | +19 |
| 209 | +explain select * from t1 where a = 2 or not(a < 10); |
| 210 | +id select_type table type possible_keys key key_len ref rows Extra |
| 211 | +1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index |
| 212 | +select * from t1 where a = 2 or not(a < 10); |
| 213 | +a |
| 214 | +2 |
| 215 | +10 |
| 216 | +11 |
| 217 | +12 |
| 218 | +13 |
| 219 | +14 |
| 220 | +15 |
| 221 | +16 |
| 222 | +17 |
| 223 | +18 |
| 224 | +19 |
| 225 | +explain select * from t1 where a > 5 and not(a > 10); |
| 226 | +id select_type table type possible_keys key key_len ref rows Extra |
| 227 | +1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index |
| 228 | +select * from t1 where a > 5 and not(a > 10); |
| 229 | +a |
| 230 | +6 |
| 231 | +7 |
| 232 | +8 |
| 233 | +9 |
| 234 | +10 |
| 235 | +explain select * from t1 where a > 5 xor a < 10; |
| 236 | +id select_type table type possible_keys key key_len ref rows Extra |
| 237 | +1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index |
| 238 | +select * from t1 where a > 5 xor a < 10; |
| 239 | +a |
| 240 | +0 |
| 241 | +1 |
| 242 | +2 |
| 243 | +3 |
| 244 | +4 |
| 245 | +5 |
| 246 | +6 |
| 247 | +7 |
| 248 | +8 |
| 249 | +9 |
| 250 | +10 |
| 251 | +11 |
| 252 | +12 |
| 253 | +13 |
| 254 | +14 |
| 255 | +15 |
| 256 | +16 |
| 257 | +17 |
| 258 | +18 |
| 259 | +19 |
| 260 | +explain select * from t1 where a = 2 or not(a < 5 or a > 15); |
| 261 | +id select_type table type possible_keys key key_len ref rows Extra |
| 262 | +1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index |
| 263 | +select * from t1 where a = 2 or not(a < 5 or a > 15); |
| 264 | +a |
| 265 | +2 |
| 266 | +5 |
| 267 | +6 |
| 268 | +7 |
| 269 | +8 |
| 270 | +9 |
| 271 | +10 |
| 272 | +11 |
| 273 | +12 |
| 274 | +13 |
| 275 | +14 |
| 276 | +15 |
| 277 | +explain select * from t1 where a = 7 or not(a < 15 and a > 5); |
| 278 | +id select_type table type possible_keys key key_len ref rows Extra |
| 279 | +1 SIMPLE t1 range a a 5 NULL 13 Using where; Using index |
| 280 | +select * from t1 where a = 7 or not(a < 15 and a > 5); |
| 281 | +a |
| 282 | +0 |
| 283 | +1 |
| 284 | +2 |
| 285 | +3 |
| 286 | +4 |
| 287 | +5 |
| 288 | +7 |
| 289 | +15 |
| 290 | +16 |
| 291 | +17 |
| 292 | +18 |
| 293 | +19 |
| 294 | +explain select * from t1 where NULL or not(a < 15 and a > 5); |
| 295 | +id select_type table type possible_keys key key_len ref rows Extra |
| 296 | +1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index |
| 297 | +select * from t1 where NULL or not(a < 15 and a > 5); |
| 298 | +a |
| 299 | +0 |
| 300 | +1 |
| 301 | +2 |
| 302 | +3 |
| 303 | +4 |
| 304 | +5 |
| 305 | +15 |
| 306 | +16 |
| 307 | +17 |
| 308 | +18 |
| 309 | +19 |
| 310 | +explain select * from t1 where not(NULL and a > 5); |
| 311 | +id select_type table type possible_keys key key_len ref rows Extra |
| 312 | +1 SIMPLE t1 range a a 5 NULL 6 Using where; Using index |
| 313 | +select * from t1 where not(NULL and a > 5); |
| 314 | +a |
| 315 | +0 |
| 316 | +1 |
| 317 | +2 |
| 318 | +3 |
| 319 | +4 |
| 320 | +5 |
| 321 | +explain select * from t1 where not(NULL or a); |
| 322 | +id select_type table type possible_keys key key_len ref rows Extra |
| 323 | +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE |
| 324 | +select * from t1 where not(NULL or a); |
| 325 | +a |
| 326 | +explain select * from t1 where not(NULL and a); |
| 327 | +id select_type table type possible_keys key key_len ref rows Extra |
| 328 | +1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index |
| 329 | +select * from t1 where not(NULL and a); |
| 330 | +a |
| 331 | +0 |
| 332 | +explain select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17)); |
| 333 | +id select_type table type possible_keys key key_len ref rows Extra |
| 334 | +1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index |
| 335 | +select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17)); |
| 336 | +a |
| 337 | +10 |
| 338 | +11 |
| 339 | +12 |
| 340 | +13 |
| 341 | +14 |
| 342 | +15 |
| 343 | +16 |
| 344 | +17 |
| 345 | +18 |
| 346 | +19 |
| 347 | +explain select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17)); |
| 348 | +id select_type table type possible_keys key key_len ref rows Extra |
| 349 | +1 SIMPLE t1 range a a 5 NULL 15 Using where; Using index |
| 350 | +select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17)); |
| 351 | +a |
| 352 | +5 |
| 353 | +6 |
| 354 | +7 |
| 355 | +8 |
| 356 | +9 |
| 357 | +10 |
| 358 | +11 |
| 359 | +12 |
| 360 | +13 |
| 361 | +14 |
| 362 | +15 |
| 363 | +16 |
| 364 | +17 |
| 365 | +18 |
| 366 | +19 |
| 367 | +explain select * from t1 where ((a between 5 and 15) and (not(a like 10))); |
| 368 | +id select_type table type possible_keys key key_len ref rows Extra |
| 369 | +1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index |
| 370 | +select * from t1 where ((a between 5 and 15) and (not(a like 10))); |
| 371 | +a |
| 372 | +5 |
| 373 | +6 |
| 374 | +7 |
| 375 | +8 |
| 376 | +9 |
| 377 | +11 |
| 378 | +12 |
| 379 | +13 |
| 380 | +14 |
| 381 | +15 |
| 382 | +drop table t1; |
0 commit comments