129
129
explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
130
130
id select_type table type possible_keys key key_len ref rows Extra
131
1 SIMPLE t2 ref fld3 fld3 122 const 1 Using where; Using index
131
1 SIMPLE t2 ref fld3 fld3 122 const # Using where; Using index
132
132
explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
133
133
id select_type table type possible_keys key key_len ref rows Extra
134
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
134
1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where
135
135
explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
136
136
id select_type table type possible_keys key key_len ref rows Extra
137
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
137
1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where
138
138
explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
139
139
id select_type table type possible_keys key key_len ref rows Extra
140
1 SIMPLE t2 ref fld3 fld3 122 const 1 Using where; Using index
140
1 SIMPLE t2 ref fld3 fld3 122 const # Using where; Using index
141
141
explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
142
142
id select_type table type possible_keys key key_len ref rows Extra
143
1 SIMPLE t2 ref fld3 fld3 122 const 1 Using where; Using index
143
1 SIMPLE t2 ref fld3 fld3 122 const # Using where; Using index
144
144
explain select fld3 from t2 ignore index (fld3,not_used);
145
145
ERROR 42000: Key 'not_used' doesn't exist in table 't2'
146
146
explain select fld3 from t2 use index (not_used);
594
582
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
595
583
id select_type table type possible_keys key key_len ref rows Extra
596
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
597
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using index
584
1 SIMPLE t2 ALL fld1 NULL NULL NULL # Using where; Using temporary; Using filesort
585
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 # Using index
598
586
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
599
587
id select_type table type possible_keys key key_len ref rows Extra
600
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
601
1 SIMPLE t3 ref period period 4 test.t1.period 4181
588
1 SIMPLE t1 ALL period NULL NULL NULL # Using temporary; Using filesort
589
1 SIMPLE t3 ref period period 4 test.t1.period #
602
590
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
603
591
id select_type table type possible_keys key key_len ref rows Extra
604
1 SIMPLE t3 index period period 4 NULL 1
605
1 SIMPLE t1 ref period period 4 test.t3.period 4181
592
1 SIMPLE t3 index period period 4 NULL #
593
1 SIMPLE t1 ref period period 4 test.t3.period #
606
594
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
607
595
id select_type table type possible_keys key key_len ref rows Extra
608
1 SIMPLE t1 index period period 4 NULL 1
609
1 SIMPLE t3 ref period period 4 test.t1.period 4181
596
1 SIMPLE t1 index period period 4 NULL #
597
1 SIMPLE t3 ref period period 4 test.t1.period #
610
598
select period from t1;
1366
1354
explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1367
1355
id select_type table type possible_keys key key_len ref rows Extra
1368
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
1356
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE
1369
1357
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
1370
1358
id select_type table type possible_keys key key_len ref rows Extra
1371
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
1359
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE
1372
1360
delete from t2 where fld1=999999;
1373
1361
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
1374
1362
id select_type table type possible_keys key key_len ref rows Extra
1375
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1376
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr 1
1363
1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where
1364
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr #
1377
1365
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
1378
1366
id select_type table type possible_keys key key_len ref rows Extra
1379
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1380
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr 1
1367
1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where
1368
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr #
1381
1369
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
1382
1370
id select_type table type possible_keys key key_len ref rows Extra
1383
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1384
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr 1
1371
1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where
1372
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr #
1385
1373
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
1386
1374
id select_type table type possible_keys key key_len ref rows Extra
1387
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1388
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1375
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL # Using where
1376
1 SIMPLE t2 ALL NULL NULL NULL NULL #
1389
1377
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
1390
1378
id select_type table type possible_keys key key_len ref rows Extra
1391
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1392
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1379
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL # Using where
1380
1 SIMPLE t2 ALL NULL NULL NULL NULL #
1393
1381
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
1394
1382
id select_type table type possible_keys key key_len ref rows Extra
1395
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1396
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1383
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL # Using where
1384
1 SIMPLE t2 ALL NULL NULL NULL NULL #
1397
1385
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
1398
1386
id select_type table type possible_keys key key_len ref rows Extra
1399
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1400
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1387
1 SIMPLE t4 ALL NULL NULL NULL NULL #
1388
1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where
1401
1389
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
1402
1390
id select_type table type possible_keys key key_len ref rows Extra
1403
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12
1404
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1391
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL #
1392
1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where
1405
1393
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
1406
1394
id select_type table type possible_keys key key_len ref rows Extra
1407
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1408
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1395
1 SIMPLE t4 ALL NULL NULL NULL NULL #
1396
1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where
1409
1397
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
1410
1398
id select_type table type possible_keys key key_len ref rows Extra
1411
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1412
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1399
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL # Using where
1400
1 SIMPLE t2 ALL NULL NULL NULL NULL #
1413
1401
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
1414
1402
id select_type table type possible_keys key key_len ref rows Extra
1415
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1416
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1403
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL # Using where
1404
1 SIMPLE t2 ALL NULL NULL NULL NULL #
1417
1405
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
1418
1406
id select_type table type possible_keys key key_len ref rows Extra
1419
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where
1420
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1407
1 SIMPLE t4 ALL NULL NULL NULL NULL # Using where
1408
1 SIMPLE t2 ALL NULL NULL NULL NULL #
1421
1409
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1422
1410
companynr companynr
1425
1413
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1426
1414
id select_type table type possible_keys key key_len ref rows Extra
1427
1 SIMPLE t4 index NULL PRIMARY 4 NULL 12 Using index; Using temporary
1428
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer
1415
1 SIMPLE t4 index NULL PRIMARY 4 NULL # Using index; Using temporary
1416
1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where; Using join buffer
1429
1417
select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
1430
1418
fld1 companynr fld3 period
1431
1419
38008 37 reporters 1008