2003-11-20 21:27:11 +01:00
|
|
|
drop table if exists t1;
|
|
|
|
create table t1
|
|
|
|
(
|
|
|
|
key1 int not null,
|
|
|
|
key2 int not null,
|
|
|
|
INDEX i1(key1),
|
2004-05-14 16:00:57 +02:00
|
|
|
INDEX i2(key2)
|
2003-12-16 18:09:22 +01:00
|
|
|
) engine=innodb;
|
2003-11-20 21:27:11 +01:00
|
|
|
explain select * from t1 where key1 < 5 or key2 > 197;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-05-29 00:04:01 +02:00
|
|
|
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
2003-11-20 21:27:11 +01:00
|
|
|
select * from t1 where key1 < 5 or key2 > 197;
|
|
|
|
key1 key2
|
|
|
|
0 200
|
|
|
|
1 199
|
|
|
|
2 198
|
|
|
|
3 197
|
|
|
|
4 196
|
|
|
|
explain select * from t1 where key1 < 3 or key2 > 195;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-05-29 00:04:01 +02:00
|
|
|
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
2003-11-20 21:27:11 +01:00
|
|
|
select * from t1 where key1 < 3 or key2 > 195;
|
|
|
|
key1 key2
|
|
|
|
0 200
|
|
|
|
1 199
|
|
|
|
2 198
|
|
|
|
3 197
|
2003-11-24 18:54:57 +01:00
|
|
|
4 196
|
2003-11-20 21:27:11 +01:00
|
|
|
alter table t1 add str1 char (255) not null,
|
|
|
|
add zeroval int not null default 0,
|
|
|
|
add str2 char (255) not null,
|
|
|
|
add str3 char (255) not null;
|
|
|
|
update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A'));
|
|
|
|
alter table t1 add primary key (str1, zeroval, str2, str3);
|
|
|
|
explain select * from t1 where key1 < 5 or key2 > 197;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-05-29 00:04:01 +02:00
|
|
|
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
2003-11-20 21:27:11 +01:00
|
|
|
select * from t1 where key1 < 5 or key2 > 197;
|
|
|
|
key1 key2 str1 zeroval str2 str3
|
|
|
|
4 196 aaa 0 bbb 196-2_a
|
2003-11-24 18:54:57 +01:00
|
|
|
3 197 aaa 0 bbb 197-1_A
|
|
|
|
2 198 aaa 0 bbb 198-1_a
|
|
|
|
1 199 aaa 0 bbb 199-0_A
|
|
|
|
0 200 aaa 0 bbb 200-0_a
|
2003-11-20 21:27:11 +01:00
|
|
|
explain select * from t1 where key1 < 3 or key2 > 195;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-05-29 00:04:01 +02:00
|
|
|
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
2003-11-20 21:27:11 +01:00
|
|
|
select * from t1 where key1 < 3 or key2 > 195;
|
|
|
|
key1 key2 str1 zeroval str2 str3
|
|
|
|
4 196 aaa 0 bbb 196-2_a
|
|
|
|
3 197 aaa 0 bbb 197-1_A
|
2003-11-24 18:54:57 +01:00
|
|
|
2 198 aaa 0 bbb 198-1_a
|
|
|
|
1 199 aaa 0 bbb 199-0_A
|
|
|
|
0 200 aaa 0 bbb 200-0_a
|
2003-11-20 21:27:11 +01:00
|
|
|
drop table t1;
|