table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 12 where used; Using index
1 FIRST t1 ref level level 1 const 12 where used; Using index
explain select level,id from t1 where level=1;
explain select level,id from t1 where level=1;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 12 where used; Using index
1 FIRST t1 ref level level 1 const 12 where used; Using index
explain select level,id,parent_id from t1 where level=1;
explain select level,id,parent_id from t1 where level=1;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 12 where used
1 FIRST t1 ref level level 1 const 12 where used
select level,id from t1 where level=1;
select level,id from t1 where level=1;
level id
level id
1 1002
1 1002
...
@@ -596,8 +596,8 @@ id parent_id level
...
@@ -596,8 +596,8 @@ id parent_id level
1025 102 2
1025 102 2
1016 102 2
1016 102 2
explain select level from t1 where level=1;
explain select level from t1 where level=1;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 ref level level 1 const 6 where used; Using index
1 FIRST t1 ref level level 1 const 6 where used; Using index
select level,id from t1 where level=1;
select level,id from t1 where level=1;
level id
level id
1 1004
1 1004
...
@@ -758,8 +758,8 @@ DROP TABLE t1;
...
@@ -758,8 +758,8 @@ DROP TABLE t1;
create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) type = innodb;
create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) type = innodb;
insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
explain select * from t1 where a > 0 and a < 50;
explain select * from t1 where a > 0 and a < 50;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 range PRIMARY PRIMARY 4 NULL 1 where used
1 FIRST t1 range PRIMARY PRIMARY 4 NULL 1 where used
drop table t1;
drop table t1;
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb;
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb;
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
...
@@ -892,29 +892,29 @@ drop table t1;
...
@@ -892,29 +892,29 @@ drop table t1;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=innodb;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=innodb;
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
explain select * from t1 order by a;
explain select * from t1 order by a;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL PRIMARY 4 NULL 4
1 FIRST t1 index NULL PRIMARY 4 NULL 4
explain select * from t1 order by b;
explain select * from t1 order by b;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL b 4 NULL 4
1 FIRST t1 index NULL b 4 NULL 4
explain select * from t1 order by c;
explain select * from t1 order by c;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 4 Using filesort
1 FIRST t1 ALL NULL NULL NULL NULL 4 Using filesort
explain select a from t1 order by a;
explain select a from t1 order by a;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL PRIMARY 4 NULL 4 Using index
1 FIRST t1 index NULL PRIMARY 4 NULL 4 Using index
explain select b from t1 order by b;
explain select b from t1 order by b;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL b 4 NULL 4 Using index
1 FIRST t1 index NULL b 4 NULL 4 Using index
explain select a,b from t1 order by b;
explain select a,b from t1 order by b;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL b 4 NULL 4 Using index
1 FIRST t1 index NULL b 4 NULL 4 Using index
explain select a,b from t1;
explain select a,b from t1;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 index NULL b 4 NULL 4 Using index
1 FIRST t1 index NULL b 4 NULL 4 Using index
explain select a,b,c from t1;
explain select a,b,c from t1;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 4
1 FIRST t1 ALL NULL NULL NULL NULL 4
drop table t1;
drop table t1;
create table t1 (t int not null default 1, key (t)) type=innodb;
create table t1 (t int not null default 1, key (t)) type=innodb;
explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
Comment
id select_type table type possible_keys key key_len ref rows Extra
Impossible WHERE
1 FIRST Impossible WHERE
select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099;
select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099;
select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3;
select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3;
fld3
fld3
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t2 ALL fld1 NULL NULL NULL 1199 where used; Using temporary; Using filesort
1 FIRST t2 ALL fld1 NULL NULL NULL 1199 where used; Using temporary; Using filesort
t3 eq_ref PRIMARY PRIMARY 4 t2.fld1 1 where used; Using index
1 FIRST t3 eq_ref PRIMARY PRIMARY 4 t2.fld1 1 where used; Using index
select period from t1;
select period from t1;
period
period
9410
9410
...
@@ -1821,9 +1821,9 @@ select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.
...
@@ -1821,9 +1821,9 @@ select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.
fld3 period
fld3 period
breaking 1001
breaking 1001
explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t2 const fld1 fld1 4 const 1
1 FIRST t2 const fld1 fld1 4 const 1
t3 const PRIMARY,period PRIMARY 4 const 1
1 FIRST t3 const PRIMARY,period PRIMARY 4 const 1
select fld3,period from t2,t1 where companynr*10 = 37*10;
select fld3,period from t2,t1 where companynr*10 = 37*10;
fld3 period
fld3 period
breaking 9410
breaking 9410
...
@@ -2561,21 +2561,21 @@ fld1 fld1
...
@@ -2561,21 +2561,21 @@ fld1 fld1
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
companynr companyname
companynr companyname
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t2 ALL NULL NULL NULL NULL 1199
1 FIRST t2 ALL NULL NULL NULL NULL 1199
t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 where used; Not exists
1 FIRST t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 where used; Not exists
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t4 ALL NULL NULL NULL NULL 12
1 FIRST t4 ALL NULL NULL NULL NULL 12
t2 ALL NULL NULL NULL NULL 1199 where used; Not exists
1 FIRST t2 ALL NULL NULL NULL NULL 1199 where used; Not exists
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
companynr companynr
companynr companynr
37 36
37 36
41 40
41 40
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t2 ALL NULL NULL NULL NULL 1199 Using temporary
1 FIRST t2 ALL NULL NULL NULL NULL 1199 Using temporary
t4 index NULL PRIMARY 1 NULL 12 where used; Using index
1 FIRST t4 index NULL PRIMARY 1 NULL 12 where used; Using index
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;
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;
fld1 companynr fld3 period
fld1 companynr fld3 period
038008 37 reporters 1008
038008 37 reporters 1008
...
@@ -3084,11 +3084,11 @@ select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr =
...
@@ -3084,11 +3084,11 @@ select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr =
fld1 sum(price)
fld1 sum(price)
038008 234298
038008 234298
explain select fld3 from t2 where 1>2 or 2>3;
explain select fld3 from t2 where 1>2 or 2>3;
Comment
id select_type table type possible_keys key key_len ref rows Extra
Impossible WHERE
1 FIRST Impossible WHERE
explain select fld3 from t2 where fld1=fld1;
explain select fld3 from t2 where fld1=fld1;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t2 ALL NULL NULL NULL NULL 1199
1 FIRST t2 ALL NULL NULL NULL NULL 1199
select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502;
select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502;
companynr fld1
companynr fld1
34 250501
34 250501
...
@@ -3139,8 +3139,8 @@ select count(*) from t3 where companynr=512 and price2=76234234;
...
@@ -3139,8 +3139,8 @@ select count(*) from t3 where companynr=512 and price2=76234234;
count(*)
count(*)
4181
4181
explain select min(fld1),max(fld1),count(*) from t2;
explain select min(fld1),max(fld1),count(*) from t2;
Comment
id select_type table type possible_keys key key_len ref rows Extra