2004-05-13 01:38:40 +04:00
|
|
|
drop table if exists t1;
|
|
|
|
create table t1
|
|
|
|
(
|
|
|
|
pk1 int not null,
|
|
|
|
pk2 int not null,
|
|
|
|
key1 int not null,
|
|
|
|
key2 int not null,
|
|
|
|
pktail1ok int not null,
|
|
|
|
pktail2ok int not null,
|
|
|
|
pktail3bad int not null,
|
|
|
|
pktail4bad int not null,
|
|
|
|
pktail5bad int not null,
|
|
|
|
pk2copy int not null,
|
|
|
|
badkey int not null,
|
|
|
|
filler1 char (200),
|
|
|
|
filler2 char (200),
|
|
|
|
key (key1),
|
|
|
|
key (key2),
|
|
|
|
/* keys with tails from CPK members */
|
|
|
|
key (pktail1ok, pk1),
|
|
|
|
key (pktail2ok, pk1, pk2),
|
|
|
|
key (pktail3bad, pk2, pk1),
|
|
|
|
key (pktail4bad, pk1, pk2copy),
|
|
|
|
key (pktail5bad, pk1, pk2, pk2copy),
|
|
|
|
primary key (pk1, pk2)
|
|
|
|
) engine=innodb;
|
|
|
|
explain select * from t1 where pk1 = 1 and pk2 < 80 and key1=0;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 ref PRIMARY,key1 PRIMARY 4 const 1 Using where
|
|
|
|
select * from t1 where pk1 = 1 and pk2 < 80 and key1=0;
|
|
|
|
pk1 pk2 key1 key2 pktail1ok pktail2ok pktail3bad pktail4bad pktail5bad pk2copy badkey filler1 filler2
|
|
|
|
1 10 0 0 0 0 0 0 0 10 0 filler-data-10 filler2
|
|
|
|
1 11 0 0 0 0 0 0 0 11 0 filler-data-11 filler2
|
|
|
|
1 12 0 0 0 0 0 0 0 12 0 filler-data-12 filler2
|
|
|
|
1 13 0 0 0 0 0 0 0 13 0 filler-data-13 filler2
|
|
|
|
1 14 0 0 0 0 0 0 0 14 0 filler-data-14 filler2
|
|
|
|
1 15 0 0 0 0 0 0 0 15 0 filler-data-15 filler2
|
|
|
|
1 16 0 0 0 0 0 0 0 16 0 filler-data-16 filler2
|
|
|
|
1 17 0 0 0 0 0 0 0 17 0 filler-data-17 filler2
|
|
|
|
1 18 0 0 0 0 0 0 0 18 0 filler-data-18 filler2
|
|
|
|
1 19 0 0 0 0 0 0 0 19 0 filler-data-19 filler2
|
|
|
|
explain select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-05-13 04:50:54 +04:00
|
|
|
1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using where; Using index
|
2004-05-13 01:38:40 +04:00
|
|
|
select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
|
|
|
|
pk1 pk2
|
|
|
|
95 50
|
|
|
|
95 51
|
|
|
|
95 52
|
|
|
|
95 53
|
|
|
|
95 54
|
|
|
|
95 55
|
|
|
|
95 56
|
|
|
|
95 57
|
|
|
|
95 58
|
|
|
|
95 59
|
|
|
|
explain select * from t1 where badkey=1 and key1=10;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 ref key1 key1 4 const 101 Using where
|
|
|
|
explain select * from t1 where pk1 < 7500 and key1 = 10;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-05-13 04:50:54 +04:00
|
|
|
1 SIMPLE t1 index_merge PRIMARY,key1 key1,PRIMARY 4,4 NULL 38 Using where
|
2004-05-13 01:38:40 +04:00
|
|
|
explain select * from t1 where pktail1ok=1 and key1=10;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-05-13 04:50:54 +04:00
|
|
|
1 SIMPLE t1 index_merge key1,pktail1ok key1,pktail1ok 4,4 NULL 1 Using where
|
2004-05-13 01:38:40 +04:00
|
|
|
explain select * from t1 where pktail2ok=1 and key1=10;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-05-13 04:50:54 +04:00
|
|
|
1 SIMPLE t1 index_merge key1,pktail2ok key1,pktail2ok 4,4 NULL 1 Using where
|
2004-05-13 01:38:40 +04:00
|
|
|
explain select * from t1 where pktail3bad=1 and key1=10;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 ref key1,pktail3bad pktail3bad 4 const 98 Using where
|
|
|
|
explain select * from t1 where pktail4bad=1 and key1=10;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 ref key1,pktail4bad pktail4bad 4 const 99 Using where
|
|
|
|
explain select * from t1 where pktail5bad=1 and key1=10;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 ref key1,pktail5bad pktail5bad 4 const 99 Using where
|
|
|
|
explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-05-13 04:50:54 +04:00
|
|
|
1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using where; Using index
|
2004-05-13 01:38:40 +04:00
|
|
|
select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
|
|
|
|
pk1 pk2 key1 key2
|
|
|
|
95 50 10 10
|
|
|
|
95 51 10 10
|
|
|
|
95 52 10 10
|
|
|
|
95 53 10 10
|
|
|
|
95 54 10 10
|
|
|
|
95 55 10 10
|
|
|
|
95 56 10 10
|
|
|
|
95 57 10 10
|
|
|
|
95 58 10 10
|
|
|
|
95 59 10 10
|
|
|
|
drop table t1;
|