80
80
Table Op Msg_type Msg_text
81
81
test.t1 check status OK
83
Table Op Msg_type Msg_text
84
test.t1 repair note The storage engine for the table doesn't support repair
84
87
id int NOT NULL auto_increment,
146
149
believe in myself
148
CREATE TEMPORARY TABLE t1 (
149
152
t1ID int NOT NULL auto_increment,
150
153
art varbinary(1) NOT NULL default '',
151
154
KNR char(5) NOT NULL default '',
218
221
explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0;
219
222
id select_type table type possible_keys key key_len ref rows Extra
220
223
1 SIMPLE t1 ref y y 5 const 1
221
1 SIMPLE t2 range x x 5 NULL 2 Using where; Using join buffer
224
1 SIMPLE t2 range x x 5 NULL 2 Using where; Using MRR; Using join buffer
222
225
explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0;
223
226
id select_type table type possible_keys key key_len ref rows Extra
224
227
1 SIMPLE t1 ref y y 5 const 1
225
1 SIMPLE t2 range x x 5 NULL 2 Using where; Using join buffer
228
1 SIMPLE t2 range x x 5 NULL 2 Using where; Using MRR; Using join buffer
226
229
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1;
227
230
id select_type table type possible_keys key key_len ref rows Extra
228
231
1 SIMPLE t1 ref y y 5 const 1
229
1 SIMPLE t2 range x x 5 NULL 3 Using where; Using join buffer
232
1 SIMPLE t2 range x x 5 NULL 3 Using where; Using MRR; Using join buffer
230
233
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1;
231
234
id select_type table type possible_keys key key_len ref rows Extra
232
235
1 SIMPLE t1 ref y y 5 const 1
233
1 SIMPLE t2 range x x 5 NULL 3 Using where; Using join buffer
236
1 SIMPLE t2 range x x 5 NULL 3 Using where; Using MRR; Using join buffer
234
237
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
235
238
id select_type table type possible_keys key key_len ref rows Extra
236
239
1 SIMPLE t1 ref y y 5 const 1
237
1 SIMPLE t2 range x x 5 NULL 2 Using where; Using join buffer
240
1 SIMPLE t2 range x x 5 NULL 2 Using where; Using MRR; Using join buffer
238
241
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
239
242
id select_type table type possible_keys key key_len ref rows Extra
240
243
1 SIMPLE t1 ref y y 5 const 1
241
1 SIMPLE t2 range x x 5 NULL 2 Using where; Using join buffer
244
1 SIMPLE t2 range x x 5 NULL 2 Using where; Using MRR; Using join buffer
242
245
explain select count(*) from t1 where x in (1);
243
246
id select_type table type possible_keys key key_len ref rows Extra
244
247
1 SIMPLE t1 ref x x 5 const 1 Using index
273
276
(33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
274
277
EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
275
278
id select_type table type possible_keys key key_len ref rows Extra
276
1 SIMPLE t1 range a,b a 5 NULL 2 Using where
279
1 SIMPLE t1 range a,b a 5 NULL 2 Using where; Using MRR
277
280
SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
304
CREATE TEMPORARY TABLE t1 (
305
308
id int NOT NULL AUTO_INCREMENT ,
306
309
line int NOT NULL default '0',
307
310
columnid int NOT NULL default '0',
351
354
name char(1) not null,
352
355
uid int not null,
353
356
primary key (id),
354
index uid_index (uid));
357
index uid_index (uid)) ENGINE=Myisam;
355
358
create table t2 (
356
359
id int not null auto_increment,
357
360
name char(1) not null,
358
361
uid int not null,
359
362
primary key (id),
360
index uid_index (uid));
363
index uid_index (uid)) engine=myisam;
361
364
insert into t1(id, uid, name) values(1, 0, ' ');
362
365
insert into t1(uid, name) values(0, ' ');
363
366
insert into t2(uid, name) select uid, name from t1;
415
418
analyze table t1,t2;
416
419
Table Op Msg_type Msg_text
417
420
test.t1 analyze status OK
418
test.t2 analyze status OK
421
test.t2 analyze status Table is already up to date
419
422
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
420
423
id select_type table type possible_keys key key_len ref rows Extra
421
1 SIMPLE # range uid_index uid_index 4 # # Using where
422
1 SIMPLE # ref uid_index uid_index 4 # #
424
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using where; Using MRR
425
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
423
426
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0;
424
427
id select_type table type possible_keys key key_len ref rows Extra
425
1 SIMPLE # range uid_index uid_index 4 # # Using where
426
1 SIMPLE # ref uid_index uid_index 4 # #
428
1 SIMPLE t1 range uid_index uid_index 4 NULL 112 Using where; Using MRR
429
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
427
430
explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
428
431
id select_type table type possible_keys key key_len ref rows Extra
429
1 SIMPLE # range uid_index uid_index 4 # # Using where
430
1 SIMPLE # ref uid_index uid_index 4 # #
432
1 SIMPLE t1 range uid_index uid_index 4 NULL 113 Using where; Using MRR
433
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
431
434
explain select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0;
432
435
id select_type table type possible_keys key key_len ref rows Extra
433
1 SIMPLE # range uid_index uid_index 4 # # Using where
434
1 SIMPLE # ref uid_index uid_index 4 # #
436
1 SIMPLE t1 range uid_index uid_index 4 NULL 113 Using where; Using MRR
437
1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
435
438
select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
436
439
id name uid id name uid
437
440
1001 A 1 1001 A 1
611
614
1 SIMPLE t1 ref a a 43 const 2 Using where
612
615
explain select * from t1 where a=binary 'aaa';
613
616
id select_type table type possible_keys key key_len ref rows Extra
614
1 SIMPLE t1 range a a 43 NULL 2 Using where
617
1 SIMPLE t1 range a a 43 NULL 2 Using where; Using MRR
615
618
explain select * from t1 where a='aaa' collate utf8_bin;
616
619
id select_type table type possible_keys key key_len ref rows Extra
617
1 SIMPLE t1 range a a 43 NULL 2 Using where
620
1 SIMPLE t1 range a a 43 NULL 2 Using where; Using MRR
619
622
CREATE TABLE t1 (
620
623
`CLIENT` char(3) collate utf8_bin NOT NULL default '000',
675
678
KEY OXLEFT (OXLEFT),
676
679
KEY OXRIGHT (OXRIGHT),
677
680
KEY OXROOTID (OXROOTID)
679
682
INSERT INTO t1 VALUES
680
683
('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'),
681
684
('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3,
694
697
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
695
698
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
696
699
id select_type table type possible_keys key key_len ref rows Extra
697
1 SIMPLE # ALL OXLEFT,OXRIGHT,OXROOTID NULL NULL # # Using where
698
1 SIMPLE # ALL OXLEFT NULL NULL # # Range checked for each record (index map: 0x4)
700
1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 130 const 5 Using where
701
1 SIMPLE s ALL OXLEFT NULL NULL NULL 6 Range checked for each record (index map: 0x4)
699
702
SELECT s.oxid FROM t1 v, t1 s
700
703
WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
701
704
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
961
964
insert into t2 select * from t1;
962
965
explain select * from t1 where a between 'a' and 'a ';
963
966
id select_type table type possible_keys key key_len ref rows Extra
964
1 SIMPLE # ref a a 43 # # Using where
967
1 SIMPLE t1 ref a a 43 const # Using where
965
968
explain select * from t1 where a = 'a' or a='a ';
966
969
id select_type table type possible_keys key key_len ref rows Extra
967
1 SIMPLE # ref a a 43 # # Using where
970
1 SIMPLE t1 ref a a 43 const # Using where
968
971
explain select * from t2 where a between 'a' and 'a ';
969
972
id select_type table type possible_keys key key_len ref rows Extra
970
1 SIMPLE # ref a a 43 # # Using where
973
1 SIMPLE t2 ref a a 43 const # Using where
971
974
explain select * from t2 where a = 'a' or a='a ';
972
975
id select_type table type possible_keys key key_len ref rows Extra
973
1 SIMPLE # ref a a 43 # # Using where
976
1 SIMPLE t2 ref a a 43 const # Using where
974
977
update t1 set a='b' where a<>'a';
975
978
explain select * from t1 where a not between 'b' and 'b';
976
979
id select_type table type possible_keys key key_len ref rows Extra
977
1 SIMPLE # ALL a NULL NULL # # Using where
980
1 SIMPLE t1 ALL a NULL NULL NULL # Using where
978
981
select a, hex(filler) from t1 where a not between 'b' and 'b';
999
1002
EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c;
1000
1003
id select_type table type possible_keys key key_len ref rows Extra
1001
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 2 Using where
1004
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 2 Using where; Using MRR
1002
1005
EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
1003
1006
id select_type table type possible_keys key key_len ref rows Extra
1004
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 2 Using where
1007
1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 2 Using where; Using MRR
1005
1008
SELECT * FROM t1 WHERE 0 < b OR 0 > c;
1017
1020
id select_type table type possible_keys key key_len ref rows Extra
1018
1021
1 SIMPLE t1 ALL idx1,idx2 NULL NULL NULL 10 Using where
1020
CREATE TEMPORARY TABLE t1 (
1021
1024
item char(20) NOT NULL default '',
1022
1025
started datetime,
1023
1026
price decimal(16,3) NOT NULL default '0.000',
1030
1033
('A2','2005-12-01 08:00:00',1000);
1031
1034
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
1032
1035
id select_type table type possible_keys key key_len ref rows Extra
1033
1 SIMPLE # range PRIMARY PRIMARY 90 # # Using where
1036
1 SIMPLE t1 range PRIMARY PRIMARY 90 NULL 1 Using where; Using MRR
1034
1037
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
1035
1038
item started price
1036
1039
A1 2005-11-01 08:00:00 1000.000
1113
1116
create table t1 (a int);
1114
1117
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
1115
create table t2 (a int, b int, filler char(100));
1118
create table t2 (a int, b int, filler char(100)) ENGINE=myisam;
1116
1119
insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A,
1117
1120
t1 B, t1 C where A.a < 5;
1118
1121
insert into t2 select 1000, b, 'filler' from t2;
1120
1123
select 'In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)' Z;
1122
1125
In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)
1123
create temporary table t2e like t2;
1124
alter table t2e engine=myisam;
1125
insert into t2e select * from t2;
1127
Table Op Msg_type Msg_text
1128
test.t2e analyze note The storage engine for the table doesn't support analyze
1129
explain select * from t2e where a=1000 and b<11;
1126
explain select * from t2 where a=1000 and b<11;
1130
1127
id select_type table type possible_keys key key_len ref rows Extra
1131
1 SIMPLE t2e ref a a 5 const 11 Using where
1128
1 SIMPLE t2 ref a a 5 const 502 Using where
1132
1129
drop table t1, t2;
1133
1130
End of 5.1 tests
1134
1131
CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));