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