131
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 1275 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 1275 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
140
1 SIMPLE t2 ref fld3 fld3 122 const 1 Using where; Using index
598
1168
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
599
1169
id select_type table type possible_keys key key_len ref rows Extra
600
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1275 Using where; Using temporary; Using filesort
1170
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
601
1171
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using index
602
1172
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
603
1173
id select_type table type possible_keys key key_len ref rows Extra
604
1 SIMPLE t1 ALL period NULL NULL NULL 42017 Using temporary; Using filesort
605
1 SIMPLE t3 ref period period 4 test.t1.period 21008
1174
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
1175
1 SIMPLE t3 ref period period 4 test.t1.period 4181
606
1176
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
607
1177
id select_type table type possible_keys key key_len ref rows Extra
608
1178
1 SIMPLE t3 index period period 4 NULL 1
609
1 SIMPLE t1 ref period period 4 test.t3.period 21008
1179
1 SIMPLE t1 ref period period 4 test.t3.period 4181
610
1180
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
611
1181
id select_type table type possible_keys key key_len ref rows Extra
612
1182
1 SIMPLE t1 index period period 4 NULL 1
613
1 SIMPLE t3 ref period period 4 test.t1.period 21008
1183
1 SIMPLE t3 ref period period 4 test.t1.period 4181
614
1184
select period from t1;
1283
1853
18601 vacuuming 1001 5987435 234724
1284
1854
18801 inch 1001 5987435 234724
1285
1855
18811 repetitions 1001 5987435 234724
1856
19101 ventilate 1001 5987435 234724
1857
19201 Graves 1001 5987435 234724
1858
30501 neonatal 1001 5987435 234724
1859
31901 realtor 1001 5987435 234724
1860
36001 elite 1001 5987435 234724
1861
38001 Conley 1001 5987435 234724
1862
38011 groupings 1001 5987435 234724
1863
38101 rusting 1001 5987435 234724
1864
38201 resumes 1001 5987435 234724
1286
1865
create table t4 (
1287
1866
companynr int NOT NULL default '00',
1288
1867
companyname char(30) NOT NULL default '',
1357
1936
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1358
1937
id select_type table type possible_keys key key_len ref rows Extra
1359
1 SIMPLE t2 ALL NULL NULL NULL NULL 1276
1938
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200
1360
1939
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr 1 Using where; Not exists
1361
1940
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
1362
1941
id select_type table type possible_keys key key_len ref rows Extra
1363
1942
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1364
1 SIMPLE t2 ALL NULL NULL NULL NULL 1276 Using where; Not exists
1943
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists
1365
1944
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1366
1945
companynr companyname
1367
1946
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
1376
1955
delete from t2 where fld1=999999;
1377
1956
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
1378
1957
id select_type table type possible_keys key key_len ref rows Extra
1379
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275 Using where
1958
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1380
1959
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr 1
1381
1960
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
1382
1961
id select_type table type possible_keys key key_len ref rows Extra
1383
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275 Using where
1962
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1384
1963
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr 1
1385
1964
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
1386
1965
id select_type table type possible_keys key key_len ref rows Extra
1387
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275 Using where
1966
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1388
1967
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t2.companynr 1
1389
1968
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
1390
1969
id select_type table type possible_keys key key_len ref rows Extra
1391
1970
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1392
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275
1971
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1393
1972
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
1394
1973
id select_type table type possible_keys key key_len ref rows Extra
1395
1974
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1396
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275
1975
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1397
1976
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
1398
1977
id select_type table type possible_keys key key_len ref rows Extra
1399
1978
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1400
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275
1979
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1401
1980
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
1402
1981
id select_type table type possible_keys key key_len ref rows Extra
1403
1982
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1404
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275 Using where
1983
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1405
1984
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
1406
1985
id select_type table type possible_keys key key_len ref rows Extra
1407
1986
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12
1408
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275 Using where
1987
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1409
1988
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
1410
1989
id select_type table type possible_keys key key_len ref rows Extra
1411
1990
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1412
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275 Using where
1991
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1413
1992
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
1414
1993
id select_type table type possible_keys key key_len ref rows Extra
1415
1994
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1416
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275
1995
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1417
1996
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
1418
1997
id select_type table type possible_keys key key_len ref rows Extra
1419
1998
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1420
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275
1999
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1421
2000
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
1422
2001
id select_type table type possible_keys key key_len ref rows Extra
1423
2002
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where
1424
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275
2003
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1425
2004
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1426
2005
companynr companynr
1503
2082
70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069
1504
2083
explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
1505
2084
id select_type table type possible_keys key key_len ref rows filtered Extra
1506
1 SIMPLE t2 ALL NULL NULL NULL NULL 1275 100.00 Using where
2085
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where
1508
2087
Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))
1509
2088
select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
2085
2664
Field Type Collation Null Key Default Extra Privileges Comment
2086
2665
show keys from t2;
2087
2666
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
2088
t2 0 PRIMARY 1 auto A 1275 NULL NULL BTREE
2089
t2 0 fld1 1 fld1 A 1275 NULL NULL BTREE
2090
t2 1 fld3 1 fld3 A 1275 NULL NULL BTREE
2667
t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE
2668
t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE
2669
t2 1 fld3 1 fld3 A NULL NULL NULL BTREE
2091
2670
drop table t4, t3, t2, t1;
2092
2671
CREATE TABLE t1 (
2093
2672
cont_nr int NOT NULL auto_increment,