mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
* New index_merge EXPLAIN output format
* Fixed a problem with wrong query results for partially covering keys in ROR-index_merge * ROR-intersection retrieval plan choice algorithm now uses less disk IO - and properly processes clustered PK range scans * Fixed several minor range optimizer problems * Added more comments * Code cleanup mysql-test/r/index_merge.result: New index_merge EXPLAIN output format changes mysql-test/r/index_merge_innodb.result: New index_merge EXPLAIN output format changes mysql-test/r/index_merge_ror.result: New index_merge EXPLAIN output format changes Added test for scans on keys that cover fields partially Fixed a minor ROR optimizer problem mysql-test/r/index_merge_ror_cpk.result: More tests added mysql-test/t/index_merge_ror.test: New index_merge EXPLAIN output format changes Added test for scans on keys that cover fields partially Fixed a minor ROR optimizer problem mysql-test/t/index_merge_ror_cpk.test: More tests added mysys/my_bitmap.c: Comments added, code cleanup sql/opt_range.cc: Comments added, code cleanup Numerous fixes, see changeset description sql/opt_range.h: Comments added, code cleanup New index_merge EXPLAIN output format related changes sql/sql_select.cc: Comments added, code cleanup New index_merge EXPLAIN output
This commit is contained in:
parent
aa2bd8ec73
commit
1ce1880204
10 changed files with 1142 additions and 483 deletions
|
@ -21,7 +21,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
explain
|
||||
select * from t0 where key1 < 3 or key2 > 1020;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 31 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 31 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where key1 < 3 or key2 > 1020;
|
||||
key1 key2 key3 key4 key5 key6 key7 key8
|
||||
1 1 1 1 1 1 1 1023
|
||||
|
@ -32,11 +32,11 @@ key1 key2 key3 key4 key5 key6 key7 key8
|
|||
1024 1024 1024 1024 1024 1024 1024 0
|
||||
explain select * from t0 where key1 < 3 or key2 <4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using sort_union(i1,i2); Using where
|
||||
explain
|
||||
select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 9 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 9 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
|
||||
key1 key2 key3 key4 key5 key6 key7 key8
|
||||
31 31 31 31 31 31 31 993
|
||||
|
@ -56,18 +56,18 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t0 ref i1,i2,i3 i3 4 const 1 Using where
|
||||
explain select * from t0 use index (i1,i2) where (key1 < 3 or key2 <4) and key3 = 50;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using sort_union(i1,i2); Using where
|
||||
explain select * from t0 where (key1 > 1 or key2 > 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL i1,i2 NULL NULL NULL 1024 Using where
|
||||
explain select * from t0 force index (i1,i2) where (key1 > 1 or key2 > 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 1024 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 1024 Using sort_union(i1,i2); Using where
|
||||
explain
|
||||
select * from t0 where key1<3 or key2<3 or (key1>5 and key1<8) or
|
||||
(key1>10 and key1<12) or (key2>100 and key2<110);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 17 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 17 Using sort_union(i1,i2); Using where
|
||||
explain select * from t0 where key2 = 45 or key1 <=> null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 range i1,i2 i2 4 NULL 1 Using where
|
||||
|
@ -79,26 +79,26 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t0 range i1,i2 i2 4 NULL 1 Using where
|
||||
explain select * from t0 where key2=10 or key3=3 or key4 <=> null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i2,i3,i4 i2,i3 4,4 NULL 2 Using where
|
||||
1 SIMPLE t0 index_merge i2,i3,i4 i2,i3 4,4 NULL 2 Using union(i2,i3); Using where
|
||||
explain select * from t0 where key2=10 or key3=3 or key4 is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i2,i3,i4 i2,i3 4,4 NULL 2 Using where
|
||||
1 SIMPLE t0 index_merge i2,i3,i4 i2,i3 4,4 NULL 2 Using union(i2,i3); Using where
|
||||
explain select key1 from t0 where (key1 <=> null) or (key2 < 5) or
|
||||
(key3=10) or (key4 <=> null);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4 i2,i3 4,4 NULL 6 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4 i2,i3 4,4 NULL 6 Using sort_union(i2,i3); Using where
|
||||
explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or
|
||||
(key3=10) or (key4 <=> null);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i3,i4 i1,i3 4,4 NULL 5 Using where
|
||||
1 SIMPLE t0 index_merge i1,i3,i4 i1,i3 4,4 NULL 5 Using sort_union(i1,i3); Using where
|
||||
explain select * from t0 where
|
||||
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 5 or key6 < 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL 6 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL 6 Using sort_union(i1,i2); Using where
|
||||
explain
|
||||
select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 9 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 9 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
|
||||
key1 key2 key3 key4 key5 key6 key7 key8
|
||||
1 1 1 1 1 1 1 1023
|
||||
|
@ -109,7 +109,7 @@ key1 key2 key3 key4 key5 key6 key7 key8
|
|||
explain select * from t0 where
|
||||
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 2 or key6 < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL 6 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i4,i5,i6 i1,i2 4,4 NULL 6 Using sort_union(i1,i2); Using where
|
||||
explain select * from t0 where
|
||||
(key1 < 3 or key2 < 3) and (key3 < 100);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -129,7 +129,7 @@ explain select * from t0 where
|
|||
or
|
||||
key1 < 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 10 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL 10 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where
|
||||
((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4))
|
||||
or
|
||||
|
@ -146,25 +146,25 @@ explain select * from t0 where
|
|||
or
|
||||
((key5 < 5 or key6 < 6) and (key7 <7 or key8 < 4));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i1,i2,i5,i6 4,4,4,4 NULL 19 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i1,i2,i5,i6 4,4,4,4 NULL 19 Using sort_union(i1,i2,i5,i6); Using where
|
||||
explain select * from t0 where
|
||||
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
|
||||
or
|
||||
((key7 <7 or key8 < 4) and (key5 < 5 or key6 < 6));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i3,i5,i7,i8 4,4,4,4 NULL 21 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7,i8 i3,i5,i7,i8 4,4,4,4 NULL 21 Using sort_union(i3,i5,i7,i8); Using where
|
||||
explain select * from t0 where
|
||||
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
|
||||
or
|
||||
((key3 <7 or key5 < 2) and (key5 < 5 or key6 < 6));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL 11 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL 11 Using sort_union(i3,i5); Using where
|
||||
explain select * from t0 where
|
||||
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
|
||||
or
|
||||
(((key3 <7 and key7 < 6) or key5 < 2) and (key5 < 5 or key6 < 6));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7 i3,i5 4,4 NULL 11 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7 i3,i5 4,4 NULL 11 Using sort_union(i3,i5); Using where
|
||||
explain select * from t0 where
|
||||
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
|
||||
or
|
||||
|
@ -176,7 +176,7 @@ explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
|
|||
or
|
||||
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 0,4 NULL 1024 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 0,4 NULL 1024 Using sort_union(i3,i5); Using where
|
||||
select * from t0 where key1 < 5 or key8 < 4 order by key1;
|
||||
key1 key2 key3 key4 key5 key6 key7 key8
|
||||
1 1 1 1 1 1 1 1023
|
||||
|
@ -190,7 +190,7 @@ key1 key2 key3 key4 key5 key6 key7 key8
|
|||
explain
|
||||
select * from t0 where key1 < 5 or key8 < 4 order by key1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i8 i1,i8 4,4 NULL 9 Using where; Using filesort
|
||||
1 SIMPLE t0 index_merge i1,i8 i1,i8 4,4 NULL 9 Using sort_union(i1,i8); Using where; Using filesort
|
||||
create table t2 like t0;
|
||||
insert into t2 select * from t0;
|
||||
alter table t2 add index i1_3(key1, key3);
|
||||
|
@ -200,7 +200,7 @@ alter table t2 drop index i2;
|
|||
alter table t2 add index i321(key3, key2, key1);
|
||||
explain select key3 from t2 where key1 = 100 or key2 = 100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL 2 Using where
|
||||
1 SIMPLE t2 index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL 2 Using sort_union(i1_3,i2_3); Using where
|
||||
explain select key3 from t2 where key1 <100 or key2 < 100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index i1_3,i2_3 i321 12 NULL 1024 Using where; Using index
|
||||
|
@ -226,7 +226,7 @@ key1a key1b key2 key2_1 key2_2 key3
|
|||
4 4 0 4 4 4
|
||||
explain select * from t4 where key1a = 3 or key1b = 4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t4 index_merge i1a,i1b i1a,i1b 4,4 NULL 2 Using where
|
||||
1 SIMPLE t4 index_merge i1a,i1b i1a,i1b 4,4 NULL 2 Using sort_union(i1a,i1b); Using where
|
||||
explain select * from t4 where key2 = 1 and (key2_1 = 1 or key3 = 5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t4 ref i2_1,i2_2 i2_1 4 const 10 Using where
|
||||
|
@ -241,7 +241,7 @@ insert into t1 select * from t0;
|
|||
explain select * from t0 left join t1 on (t0.key1=t1.key1)
|
||||
where t0.key1=3 or t0.key2=4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
|
||||
1 SIMPLE t1 ref i1 i1 4 test.t0.key1 1
|
||||
select * from t0 left join t1 on (t0.key1=t1.key1)
|
||||
where t0.key1=3 or t0.key2=4;
|
||||
|
@ -251,13 +251,13 @@ key1 key2 key3 key4 key5 key6 key7 key8 key1 key2 key3 key4 key5 key6 key7 key8
|
|||
explain
|
||||
select * from t0,t1 where (t0.key1=t1.key1) and ( t0.key1=3 or t0.key2=4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
|
||||
1 SIMPLE t1 ref i1 i1 4 test.t0.key1 1
|
||||
explain
|
||||
select * from t0,t1 where (t0.key1=t1.key1) and
|
||||
(t0.key1=3 or t0.key2=4) and t1.key1<200;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
|
||||
1 SIMPLE t1 ref i1 i1 4 test.t0.key1 1 Using where
|
||||
explain
|
||||
select * from t0,t1 where (t0.key1=t1.key1) and
|
||||
|
@ -269,7 +269,7 @@ explain select * from t0,t1 where t0.key1 = 5 and
|
|||
(t1.key1 = t0.key1 or t1.key8 = t0.key1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ref i1 i1 4 const 1 Using where
|
||||
1 SIMPLE t1 index_merge i1,i8 i1,i8 4,4 NULL 2 Using where
|
||||
1 SIMPLE t1 index_merge i1,i8 i1,i8 4,4 NULL 2 Using union(i1,i8); Using where
|
||||
explain select * from t0,t1 where t0.key1 < 3 and
|
||||
(t1.key1 = t0.key1 or t1.key8 = t0.key1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -278,12 +278,12 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
explain select * from t1 where key1=3 or key2=4
|
||||
union select * from t1 where key1<4 or key3=5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using where
|
||||
2 UNION t1 index_merge i1,i3 i1,i3 4,4 NULL 5 Using where
|
||||
1 PRIMARY t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
|
||||
2 UNION t1 index_merge i1,i3 i1,i3 4,4 NULL 5 Using sort_union(i1,i3); Using where
|
||||
explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
|
||||
2 DERIVED t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using where
|
||||
2 DERIVED t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
|
||||
create table t3 like t0;
|
||||
insert into t3 select * from t0;
|
||||
alter table t3 add key9 int not null, add index i9(key9);
|
||||
|
@ -296,7 +296,7 @@ key1=1 or key2=2 or key3=3 or key4=4 or
|
|||
key5=5 or key6=6 or key7=7 or key8=8 or
|
||||
key9=9 or keyA=10 or keyB=11 or keyC=12;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 index_merge i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC 4,4,4,4,4,4,4,4,4,4,4,4 NULL 12 Using where
|
||||
1 SIMPLE t3 index_merge i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC 4,4,4,4,4,4,4,4,4,4,4,4 NULL 12 Using union(i1,i2,i3,i4,i5,i6,i7,i8,i9,iA,iB,iC); Using where
|
||||
select * from t3 where
|
||||
key1=1 or key2=2 or key3=3 or key4=4 or
|
||||
key5=5 or key6=6 or key7=7 or key8=8 or
|
||||
|
@ -316,7 +316,7 @@ key1 key2 key3 key4 key5 key6 key7 key8 key9 keyA keyB keyC
|
|||
1016 1016 1016 1016 1016 1016 1016 8 1016 1016 1016 1016
|
||||
explain select * from t0 where key1 < 3 or key2 < 4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using where
|
||||
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL 7 Using sort_union(i1,i2); Using where
|
||||
select * from t0 where key1 < 3 or key2 < 4;
|
||||
key1 key2 key3 key4 key5 key6 key7 key8
|
||||
1 1 1 1 1 1 1 1023
|
||||
|
|
|
@ -8,7 +8,7 @@ INDEX i2(key2),
|
|||
) engine=innodb;
|
||||
explain select * from t1 where key1 < 5 or key2 > 197;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using where
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
select * from t1 where key1 < 5 or key2 > 197;
|
||||
key1 key2
|
||||
0 200
|
||||
|
@ -18,7 +18,7 @@ key1 key2
|
|||
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
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using where
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
select * from t1 where key1 < 3 or key2 > 195;
|
||||
key1 key2
|
||||
0 200
|
||||
|
@ -34,7 +34,7 @@ update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if
|
|||
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
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using where
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
select * from t1 where key1 < 5 or key2 > 197;
|
||||
key1 key2 str1 zeroval str2 str3
|
||||
4 196 aaa 0 bbb 196-2_a
|
||||
|
@ -44,7 +44,7 @@ key1 key2 str1 zeroval str2 str3
|
|||
0 200 aaa 0 bbb 200-0_a
|
||||
explain select * from t1 where key1 < 3 or key2 > 195;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using where
|
||||
1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where
|
||||
select * from t1 where key1 < 3 or key2 > 195;
|
||||
key1 key2 str1 zeroval str2 str3
|
||||
4 196 aaa 0 bbb 196-2_a
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
drop table if exists t1,t0;
|
||||
drop table if exists t0,t1,t2;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
64801
|
||||
explain select key1,key2 from t1 where key1=100 and key2=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using intersect(key1,key2); Using where; Using index
|
||||
select key1,key2 from t1 where key1=100 and key2=100;
|
||||
key1 key2
|
||||
100 100
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
key1 key2 key3 key4 filler1
|
||||
100 100 100 100 key1-key2-key3-key4
|
||||
|
@ -18,21 +18,21 @@ insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, -1, -1, 'key1
|
|||
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 100, 100, 'key4-key3');
|
||||
explain select key1,key2,filler1 from t1 where key1=100 and key2=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using intersect(key1,key2); Using where
|
||||
select key1,key2,filler1 from t1 where key1=100 and key2=100;
|
||||
key1 key2 filler1
|
||||
100 100 key1-key2-key3-key4
|
||||
100 100 key1-key2
|
||||
explain select key1,key2 from t1 where key1=100 and key2=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using intersect(key1,key2); Using where; Using index
|
||||
select key1,key2 from t1 where key1=100 and key2=100;
|
||||
key1 key2
|
||||
100 100
|
||||
100 100
|
||||
explain select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
|
||||
select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
key1 key2 key3 key4
|
||||
100 100 100 100
|
||||
|
@ -40,7 +40,7 @@ key1 key2 key3 key4
|
|||
-1 -1 100 100
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
key1 key2 key3 key4 filler1
|
||||
100 100 100 100 key1-key2-key3-key4
|
||||
|
@ -48,14 +48,14 @@ key1 key2 key3 key4 filler1
|
|||
-1 -1 100 100 key4-key3
|
||||
explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 1 Using intersect(key1,key2,key3); Using where; Using index
|
||||
select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100;
|
||||
key1 key2 key3
|
||||
100 100 100
|
||||
insert into t1 (key1,key2,key3,key4,filler1) values (101,101,101,101, 'key1234-101');
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 5 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3 key1,key2,key3 5,5,5 NULL 5 Using union(intersect(key1,key2),key3); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101;
|
||||
key1 key2 key3 key4 filler1
|
||||
100 100 100 100 key1-key2-key3-key4
|
||||
|
@ -72,19 +72,19 @@ select key1,key2,filler1 from t1 where key2=100 and key2=200;
|
|||
key1 key2 filler1
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
key1 key2 key3 key4 filler1
|
||||
-1 -1 100 100 key4-key3
|
||||
delete from t1 where key3=100 and key4=100;
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key1,key2,key3,key4 5,5,5,5 NULL 8 Using union(intersect(key1,key2),intersect(key3,key4)); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100;
|
||||
key1 key2 key3 key4 filler1
|
||||
explain select key1,key2 from t1 where key1=100 and key2=100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using where; Using index
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 3 Using intersect(key1,key2); Using where; Using index
|
||||
select key1,key2 from t1 where key1=100 and key2=100;
|
||||
key1 key2
|
||||
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-1');
|
||||
|
@ -92,7 +92,7 @@ insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key
|
|||
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-3');
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 16 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 16 Using union(key3,intersect(key1,key2),key4); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
key1 key2 key3 key4 filler1
|
||||
100 100 200 200 key1-key2-key3-key4-3
|
||||
|
@ -101,7 +101,7 @@ key1 key2 key3 key4 filler1
|
|||
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, -1, 200,'key4');
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 18 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 18 Using union(key3,intersect(key1,key2),key4); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
key1 key2 key3 key4 filler1
|
||||
100 100 200 200 key1-key2-key3-key4-3
|
||||
|
@ -111,7 +111,7 @@ key1 key2 key3 key4 filler1
|
|||
insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 200, -1,'key3');
|
||||
explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 20 Using where
|
||||
1 SIMPLE t1 index_merge key1,key2,key3,key4 key3,key1,key2,key4 5,5,5,5 NULL 20 Using union(key3,intersect(key1,key2),key4); Using where
|
||||
select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200;
|
||||
key1 key2 key3 key4 filler1
|
||||
100 100 200 200 key1-key2-key3-key4-3
|
||||
|
@ -121,10 +121,10 @@ key1 key2 key3 key4 filler1
|
|||
-1 -1 200 -1 key3
|
||||
explain select * from t1 where st_a=1 and st_b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b st_a,st_b 4,4 NULL 2508 Using where
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b st_a,st_b 4,4 NULL 2508 Using intersect(st_a,st_b); Using where
|
||||
explain select st_a,st_b from t1 where st_a=1 and st_b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b st_a,st_b 4,4 NULL 2508 Using where; Using index
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b st_a,st_b 4,4 NULL 2508 Using intersect(st_a,st_b); Using where; Using index
|
||||
explain select st_a from t1 ignore index (st_a) where st_a=1 and st_b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,stb_swt1a_2b,stb_swt1b,st_b st_b 4 const 14720 Using where
|
||||
|
@ -136,33 +136,60 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t1 ref stb_swt1a_2b,stb_swt1b,st_b stb_swt1b 8 const,const 3757 Using where
|
||||
explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL 42 Using where
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL 42 Using intersect(sta_swt12a,stb_swt1a_2b); Using where
|
||||
explain select * from t1 ignore index (sta_swt21a, stb_swt1a_2b)
|
||||
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt12a,stb_swt1b 12,8 NULL 42 Using where
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt12a,stb_swt1b 12,8 NULL 42 Using intersect(sta_swt12a,stb_swt1b); Using where
|
||||
explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b)
|
||||
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using where
|
||||
1 SIMPLE t1 index_merge sta_swt1a,sta_swt2a,st_a,stb_swt1b,st_b sta_swt1a,sta_swt2a,stb_swt1b 8,8,8 NULL 41 Using intersect(sta_swt1a,sta_swt2a,stb_swt1b); Using where
|
||||
explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b, stb_swt1b)
|
||||
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt1a,sta_swt2a,st_a,st_b sta_swt1a,st_b 8,4 NULL 640 Using where
|
||||
1 SIMPLE t1 index_merge sta_swt1a,sta_swt2a,st_a,st_b sta_swt1a,sta_swt2a,st_b 8,8,4 NULL 159 Using intersect(sta_swt1a,sta_swt2a,st_b); Using where
|
||||
explain select * from t1
|
||||
where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL 42 Using where
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt12a,stb_swt1a_2b 12,12 NULL 42 Using intersect(sta_swt12a,stb_swt1a_2b); Using where
|
||||
explain select * from t1
|
||||
where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using where
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using intersect(sta_swt1a,stb_swt1b); Using where
|
||||
explain select st_a from t1
|
||||
where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using where; Using index
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
|
||||
explain select st_a from t1
|
||||
where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using where; Using index
|
||||
1 SIMPLE t1 index_merge sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b sta_swt1a,stb_swt1b 8,8 NULL 163 Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
|
||||
drop table t0,t1;
|
||||
create table t2 (
|
||||
a char(10),
|
||||
b char(10),
|
||||
filler1 char(255),
|
||||
filler2 char(255),
|
||||
key(a(5)),
|
||||
key(b(5))
|
||||
);
|
||||
select count(a) from t2 where a='BBBBBBBB';
|
||||
count(a)
|
||||
4
|
||||
select count(a) from t2 where b='BBBBBBBB';
|
||||
count(a)
|
||||
4
|
||||
explain select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref a,b a 6 const 4 Using where
|
||||
select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA';
|
||||
count(a)
|
||||
4
|
||||
select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA';
|
||||
count(a)
|
||||
4
|
||||
insert into t2 values ('ab', 'ab', 'uh', 'oh');
|
||||
explain select a from t2 where a='ab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref a a 6 const 1 Using where
|
||||
|
|
|
@ -41,7 +41,7 @@ pk1 pk2 key1 key2 pktail1ok pktail2ok pktail3bad pktail4bad pktail5bad pk2copy b
|
|||
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
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using intersect(key1,key2); Using where; Using index
|
||||
select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
|
||||
pk1 pk2
|
||||
95 50
|
||||
|
@ -59,13 +59,19 @@ 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
|
||||
1 SIMPLE t1 index_merge PRIMARY,key1 key1,PRIMARY 4,4 NULL 38 Using where
|
||||
1 SIMPLE t1 index_merge PRIMARY,key1 key1,PRIMARY 4,4 NULL 38 Using intersect(key1,PRIMARY); Using where
|
||||
explain select * from t1 where pktail1ok=1 and key1=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,pktail1ok key1,pktail1ok 4,4 NULL 1 Using where
|
||||
1 SIMPLE t1 index_merge key1,pktail1ok key1,pktail1ok 4,4 NULL 1 Using intersect(key1,pktail1ok); Using where
|
||||
explain select * from t1 where pktail2ok=1 and key1=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge key1,pktail2ok key1,pktail2ok 4,4 NULL 1 Using where
|
||||
1 SIMPLE t1 index_merge key1,pktail2ok key1,pktail2ok 4,4 NULL 1 Using intersect(key1,pktail2ok); Using where
|
||||
select ' The following is actually a deficiency, it uses sort_union currently:' as 'note:';
|
||||
note:
|
||||
The following is actually a deficiency, it uses sort_union currently:
|
||||
explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge PRIMARY,key1,pktail2ok pktail2ok,key1 8,4 NULL 199 Using sort_union(pktail2ok,key1); Using where
|
||||
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
|
||||
|
@ -77,7 +83,7 @@ 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
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using where; Using index
|
||||
1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using intersect(key1,key2); Using where; Using index
|
||||
select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
|
||||
pk1 pk2 key1 key2
|
||||
95 50 10 10
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# ROR-index_merge tests.
|
||||
#
|
||||
--disable_warnings
|
||||
drop table if exists t1,t0;
|
||||
drop table if exists t0,t1,t2;
|
||||
--enable_warnings
|
||||
--disable_query_log
|
||||
create table t1
|
||||
|
@ -213,3 +213,37 @@ explain select st_a from t1
|
|||
|
||||
drop table t0,t1;
|
||||
|
||||
# 'Partially' covered fields test
|
||||
|
||||
create table t2 (
|
||||
a char(10),
|
||||
b char(10),
|
||||
filler1 char(255),
|
||||
filler2 char(255),
|
||||
key(a(5)),
|
||||
key(b(5))
|
||||
);
|
||||
|
||||
--disable_query_log
|
||||
let $1=8;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t2 values (repeat(char($1+64), 8),repeat(char($1+64), 8),'filler1', 'filler2');
|
||||
dec $1;
|
||||
}
|
||||
insert into t2 select * from t2;
|
||||
insert into t2 select * from t2;
|
||||
--enable_query_log
|
||||
|
||||
# The table row buffer is reused. Fill it with rows that don't match.
|
||||
select count(a) from t2 where a='BBBBBBBB';
|
||||
select count(a) from t2 where b='BBBBBBBB';
|
||||
|
||||
# BUG#1:
|
||||
explain select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA';
|
||||
select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA';
|
||||
select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA';
|
||||
|
||||
insert into t2 values ('ab', 'ab', 'uh', 'oh');
|
||||
explain select a from t2 where a='ab';
|
||||
drop table t2;
|
||||
|
|
|
@ -69,6 +69,9 @@ explain select * from t1 where pk1 < 7500 and key1 = 10;
|
|||
explain select * from t1 where pktail1ok=1 and key1=10;
|
||||
explain select * from t1 where pktail2ok=1 and key1=10;
|
||||
|
||||
select ' The following is actually a deficiency, it uses sort_union currently:' as 'note:';
|
||||
explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10;
|
||||
|
||||
explain select * from t1 where pktail3bad=1 and key1=10;
|
||||
explain select * from t1 where pktail4bad=1 and key1=10;
|
||||
explain select * from t1 where pktail5bad=1 and key1=10;
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
* when both arguments are bitmaps, they must be of the same size
|
||||
* bitmap_intersect() is an exception :)
|
||||
(for for Bitmap::intersect(ulonglong map2buff))
|
||||
|
||||
If THREAD is defined all bitmap operations except bitmap_init/bitmap_free
|
||||
are thread-safe.
|
||||
|
||||
TODO:
|
||||
Make assembler THREAD safe versions of these using test-and-set instructions
|
||||
|
@ -332,29 +335,36 @@ void bitmap_union(MY_BITMAP *map, const MY_BITMAP *map2)
|
|||
|
||||
|
||||
/*
|
||||
Get number of set bits in the bitmap
|
||||
SYNOPSIS
|
||||
bitmap_bits_set()
|
||||
map
|
||||
RETURN
|
||||
Number of set bits in the bitmap.
|
||||
*/
|
||||
|
||||
uint bitmap_bits_set(const MY_BITMAP *map)
|
||||
{
|
||||
uchar *m= map->bitmap,
|
||||
*end= map->bitmap+map->bitmap_size;
|
||||
uchar *m= map->bitmap;
|
||||
uchar *end= m + map->bitmap_size;
|
||||
uint res= 0;
|
||||
|
||||
DBUG_ASSERT(map->bitmap);
|
||||
|
||||
bitmap_lock((MY_BITMAP *)map);
|
||||
while (m < end)
|
||||
{
|
||||
res+= my_count_bits_ushort(*m++);
|
||||
}
|
||||
|
||||
bitmap_unlock((MY_BITMAP *)map);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Return number of first zero bit or MY_BIT_NONE if all bits are set.
|
||||
SYNOPSIS
|
||||
bitmap_get_first()
|
||||
map
|
||||
RETURN
|
||||
Number of first unset bit in the bitmap or MY_BIT_NONE if all bits are set.
|
||||
*/
|
||||
|
||||
uint bitmap_get_first(const MY_BITMAP *map)
|
||||
|
|
1154
sql/opt_range.cc
1154
sql/opt_range.cc
File diff suppressed because it is too large
Load diff
195
sql/opt_range.h
195
sql/opt_range.h
|
@ -77,27 +77,59 @@ public:
|
|||
ha_rows records; /* estimate of # of records to be retrieved */
|
||||
double read_time; /* time to perform this retrieval */
|
||||
TABLE *head;
|
||||
|
||||
/*
|
||||
index this quick select uses, or MAX_KEY for quick selects
|
||||
Index this quick select uses, or MAX_KEY for quick selects
|
||||
that use several indexes
|
||||
*/
|
||||
uint index;
|
||||
|
||||
/* applicable iff index!= MAX_KEY */
|
||||
uint max_used_key_length, used_key_parts;
|
||||
/*
|
||||
Total length of first used_key_parts parts of the key.
|
||||
Applicable if index!= MAX_KEY.
|
||||
*/
|
||||
uint max_used_key_length;
|
||||
|
||||
/*
|
||||
Max. number of (first) key parts this quick select uses for retrieval.
|
||||
eg. for "(key1p1=c1 AND key1p2=c2) OR key1p1=c2" used_key_parts == 2.
|
||||
Applicable if index!= MAX_KEY.
|
||||
*/
|
||||
uint used_key_parts;
|
||||
|
||||
QUICK_SELECT_I();
|
||||
virtual ~QUICK_SELECT_I(){};
|
||||
/*
|
||||
Call init() immediately after creation of quick select. if init() call
|
||||
fails, reset() or get_next() must not be called.
|
||||
|
||||
/*
|
||||
Do post-constructor initialization.
|
||||
SYNOPSIS
|
||||
init()
|
||||
|
||||
init() performs initializations that should have been in constructor if
|
||||
it was possible to return errors from constructors. The join optimizer may
|
||||
create and then delete quick selects without retrieving any rows so init()
|
||||
must not contain any IO or CPU intensive code.
|
||||
|
||||
If init() call fails the only valid action is to delete this quick select,
|
||||
reset() and get_next() must not be called.
|
||||
|
||||
RETURN
|
||||
0 OK
|
||||
other Error code
|
||||
*/
|
||||
virtual int init() = 0;
|
||||
|
||||
/*
|
||||
Call reset() before first get_next call. get_next must not be called if
|
||||
reset() call fails.
|
||||
Initialize quick select for row retrieval.
|
||||
SYNOPSIS
|
||||
reset()
|
||||
|
||||
reset() should be called when it is certain that row retrieval will be
|
||||
necessary. This call may do heavyweight initialization like buffering first
|
||||
N records etc. If reset() call fails get_next() must not be called.
|
||||
|
||||
RETURN
|
||||
0 OK
|
||||
other Error code
|
||||
*/
|
||||
virtual int reset(void) = 0;
|
||||
virtual int get_next() = 0; /* get next record to retrieve */
|
||||
|
@ -117,30 +149,54 @@ public:
|
|||
virtual int get_type() = 0;
|
||||
|
||||
/*
|
||||
Initialize this quick select as a child of a index union or intersection
|
||||
scan. This call replaces init() call.
|
||||
Initialize this quick select as a merged scan inside a ROR-union or a ROR-
|
||||
intersection scan. The caller must not additionally call init() if this
|
||||
function is called.
|
||||
SYNOPSIS
|
||||
init_ror_merged_scan()
|
||||
reuse_handler quick select may use (q: psergey??)
|
||||
(q: is this natural that we do it this way)
|
||||
NOTES
|
||||
psergey?
|
||||
*/
|
||||
virtual int init_ror_child_scan(bool reuse_handler)
|
||||
virtual int init_ror_merged_scan(bool reuse_handler)
|
||||
{ DBUG_ASSERT(0); return 1; }
|
||||
|
||||
virtual void cleanup_ror_child_scan() { DBUG_ASSERT(0); }
|
||||
/* Save ROWID of last retrieved row in file->ref. (psergey: or table->ref?) */
|
||||
virtual void save_last_pos(){};
|
||||
|
||||
/*
|
||||
Fill key_names with list of keys this quick select used;
|
||||
fill used_lenghth with correponding used lengths.
|
||||
Append comma-separated list of keys this quick select uses to key_names;
|
||||
append comma-separated list of corresponding used lengths to used_lengths.
|
||||
This is used by select_describe.
|
||||
*/
|
||||
virtual void fill_keys_and_lengths(String *key_names,
|
||||
String *used_lengths)=0;
|
||||
|
||||
virtual void add_keys_and_lengths(String *key_names,
|
||||
String *used_lengths)=0;
|
||||
|
||||
/*
|
||||
Append text representation of quick select structure (what and how is
|
||||
merged) to str. The result is added to "Extra" field in EXPLAIN output.
|
||||
This function is implemented only by quick selects that merge other quick
|
||||
selects output and/or can produce output suitable for merging.
|
||||
*/
|
||||
virtual void add_info_string(String *str) {};
|
||||
/*
|
||||
Return 1 if any index used by this quick select
|
||||
a) uses field that is listed in passed field list or
|
||||
b) is automatically updated (like a timestamp)
|
||||
*/
|
||||
virtual bool check_if_keys_used(List<Item> *fields);
|
||||
|
||||
/*
|
||||
rowid of last row retrieved by this quick select. This is used only
|
||||
when doing ROR-index_merge selects
|
||||
rowid of last row retrieved by this quick select. This is used only when
|
||||
doing ROR-index_merge selects
|
||||
*/
|
||||
byte *last_rowid;
|
||||
|
||||
/*
|
||||
Table record buffer used by this quick select.
|
||||
Currently this is always the same as head->record[0]. psergey: check that!
|
||||
*/
|
||||
byte *record;
|
||||
#ifndef DBUG_OFF
|
||||
/*
|
||||
|
@ -155,6 +211,10 @@ public:
|
|||
struct st_qsel_param;
|
||||
class SEL_ARG;
|
||||
|
||||
/*
|
||||
Quick select that does a range scan on a single key. The records are
|
||||
returned in key order.
|
||||
*/
|
||||
class QUICK_RANGE_SELECT : public QUICK_SELECT_I
|
||||
{
|
||||
protected:
|
||||
|
@ -163,7 +223,11 @@ public:
|
|||
int error;
|
||||
protected:
|
||||
handler *file;
|
||||
bool free_file; /* if true, this quick select "owns" file and will free it */
|
||||
/*
|
||||
If true, this quick select has its "own" handler object which should be
|
||||
closed no later then this quick select is deleted.
|
||||
*/
|
||||
bool free_file;
|
||||
|
||||
protected:
|
||||
friend
|
||||
|
@ -207,15 +271,16 @@ public:
|
|||
int get_next();
|
||||
bool reverse_sorted() { return 0; }
|
||||
bool unique_key_range();
|
||||
int init_ror_child_scan(bool reuse_handler);
|
||||
int init_ror_merged_scan(bool reuse_handler);
|
||||
void save_last_pos()
|
||||
{
|
||||
file->position(record);
|
||||
};
|
||||
int get_type() { return QS_TYPE_RANGE; }
|
||||
void fill_keys_and_lengths(String *key_names, String *used_lengths);
|
||||
void add_keys_and_lengths(String *key_names, String *used_lengths);
|
||||
void add_info_string(String *str);
|
||||
#ifndef DBUG_OFF
|
||||
virtual void dbug_dump(int indent, bool verbose);
|
||||
void dbug_dump(int indent, bool verbose);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -291,10 +356,11 @@ public:
|
|||
bool reverse_sorted() { return false; }
|
||||
bool unique_key_range() { return false; }
|
||||
int get_type() { return QS_TYPE_INDEX_MERGE; }
|
||||
void fill_keys_and_lengths(String *key_names, String *used_lengths);
|
||||
void add_keys_and_lengths(String *key_names, String *used_lengths);
|
||||
void add_info_string(String *str);
|
||||
bool check_if_keys_used(List<Item> *fields);
|
||||
#ifndef DBUG_OFF
|
||||
virtual void dbug_dump(int indent, bool verbose);
|
||||
void dbug_dump(int indent, bool verbose);
|
||||
#endif
|
||||
|
||||
bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range);
|
||||
|
@ -317,7 +383,6 @@ public:
|
|||
|
||||
THD *thd;
|
||||
int prepare_unique();
|
||||
bool reset_called;
|
||||
|
||||
/* used to get rows collected in Unique */
|
||||
READ_RECORD read_record;
|
||||
|
@ -326,9 +391,22 @@ public:
|
|||
|
||||
/*
|
||||
Rowid-Ordered Retrieval (ROR) index intersection quick select.
|
||||
This quick select produces an intersection of records returned by several
|
||||
QUICK_RANGE_SELECTs that return data ordered by rowid.
|
||||
This quick select produces intersection of row sequences returned
|
||||
by several QUICK_RANGE_SELECTs it "merges".
|
||||
|
||||
All merged QUICK_RANGE_SELECTs must return rowids in rowid order.
|
||||
QUICK_ROR_INTERSECT_SELECT will return rows in rowid order, too.
|
||||
|
||||
All merged quick selects retrieve {rowid, covered_fields} tuples (not full
|
||||
table records).
|
||||
QUICK_ROR_INTERSECT_SELECT retrieves full records if it is not being used
|
||||
by QUICK_ROR_INTERSECT_SELECT and all merged quick selects together don't
|
||||
cover needed all fields.
|
||||
|
||||
If one of the merged quick selects is a Clustered PK range scan, it is
|
||||
used only to filter rowid sequence produced by other merged quick selects.
|
||||
*/
|
||||
|
||||
class QUICK_ROR_INTERSECT_SELECT : public QUICK_SELECT_I
|
||||
{
|
||||
public:
|
||||
|
@ -343,28 +421,46 @@ public:
|
|||
bool reverse_sorted() { return false; }
|
||||
bool unique_key_range() { return false; }
|
||||
int get_type() { return QS_TYPE_ROR_INTERSECT; }
|
||||
void fill_keys_and_lengths(String *key_names, String *used_lengths);
|
||||
void add_keys_and_lengths(String *key_names, String *used_lengths);
|
||||
void add_info_string(String *str);
|
||||
bool check_if_keys_used(List<Item> *fields);
|
||||
#ifndef DBUG_OFF
|
||||
virtual void dbug_dump(int indent, bool verbose);
|
||||
void dbug_dump(int indent, bool verbose);
|
||||
#endif
|
||||
int init_ror_child_scan(bool reuse_handler);
|
||||
int init_ror_merged_scan(bool reuse_handler);
|
||||
bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range);
|
||||
|
||||
/* range quick selects this intersection consists of */
|
||||
/*
|
||||
Range quick selects this intersection consists of, not including
|
||||
cpk_quick.
|
||||
*/
|
||||
List<QUICK_RANGE_SELECT> quick_selects;
|
||||
|
||||
/*
|
||||
Merged quick select that uses Clustered PK, if there is one. This quick
|
||||
select is not used for row retrieval, it is used for row retrieval.
|
||||
*/
|
||||
QUICK_RANGE_SELECT *cpk_quick;
|
||||
MEM_ROOT alloc;
|
||||
THD *thd;
|
||||
bool reset_called;
|
||||
bool need_to_fetch_row;
|
||||
|
||||
MEM_ROOT alloc; /* Memory pool for this and merged quick selects data. */
|
||||
THD *thd; /* current thread */
|
||||
bool need_to_fetch_row; /* if true, do retrieve full table records. */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Rowid-Ordered Retrieval index union select.
|
||||
This quick select produces union of row sequences returned by several
|
||||
quick select it "merges".
|
||||
|
||||
All merged quick selects must return rowids in rowid order.
|
||||
QUICK_ROR_UNION_SELECT will return rows in rowid order, too.
|
||||
|
||||
All merged quick selects are set not to retrieve full table records.
|
||||
ROR-union quick select always retrieves full records.
|
||||
|
||||
*/
|
||||
|
||||
class QUICK_ROR_UNION_SELECT : public QUICK_SELECT_I
|
||||
{
|
||||
public:
|
||||
|
@ -377,33 +473,30 @@ public:
|
|||
bool reverse_sorted() { return false; }
|
||||
bool unique_key_range() { return false; }
|
||||
int get_type() { return QS_TYPE_ROR_UNION; }
|
||||
void fill_keys_and_lengths(String *key_names, String *used_lengths);
|
||||
void add_keys_and_lengths(String *key_names, String *used_lengths);
|
||||
void add_info_string(String *str);
|
||||
bool check_if_keys_used(List<Item> *fields);
|
||||
#ifndef DBUG_OFF
|
||||
virtual void dbug_dump(int indent, bool verbose);
|
||||
void dbug_dump(int indent, bool verbose);
|
||||
#endif
|
||||
|
||||
bool push_quick_back(QUICK_SELECT_I *quick_sel_range);
|
||||
|
||||
/* range quick selects this index_merge read consists of */
|
||||
List<QUICK_SELECT_I> quick_selects;
|
||||
List<QUICK_SELECT_I> quick_selects; /* Merged quick selects */
|
||||
|
||||
QUEUE queue;
|
||||
MEM_ROOT alloc;
|
||||
QUEUE queue; /* Priority queue for merge operation */
|
||||
MEM_ROOT alloc; /* Memory pool for this and merged quick selects data. */
|
||||
|
||||
THD *thd;
|
||||
byte *cur_rowid;
|
||||
byte *prev_rowid;
|
||||
uint rowid_length;
|
||||
bool reset_called;
|
||||
bool have_prev_rowid;
|
||||
|
||||
THD *thd; /* current thread */
|
||||
byte *cur_rowid; /* buffer used in get_next() */
|
||||
byte *prev_rowid; /* rowid of last row returned by get_next() */
|
||||
bool have_prev_rowid; /* true if prev_rowid has valid data */
|
||||
uint rowid_length; /* table rowid length */
|
||||
private:
|
||||
static int queue_cmp(void *arg, byte *val1, byte *val2);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QUICK_SELECT_DESC: public QUICK_RANGE_SELECT
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -10077,7 +10077,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||
select_result *result=join->result;
|
||||
Item *item_null= new Item_null();
|
||||
CHARSET_INFO *cs= &my_charset_latin1;
|
||||
int quick_type= -1;
|
||||
int quick_type;
|
||||
DBUG_ENTER("select_describe");
|
||||
DBUG_PRINT("info", ("Select 0x%lx, type %s, message %s",
|
||||
(ulong)join->select_lex, join->select_lex->type,
|
||||
|
@ -10104,17 +10104,20 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||
{
|
||||
JOIN_TAB *tab=join->join_tab+i;
|
||||
TABLE *table=tab->table;
|
||||
char buff[512],*buff_ptr=buff;
|
||||
char buff[512];
|
||||
char buff1[512], buff2[512], buff3[512];
|
||||
char keylen_str_buf[64];
|
||||
char derived_name[64];
|
||||
String extra(buff, sizeof(buff),cs);
|
||||
String tmp1(buff1,sizeof(buff1),cs);
|
||||
String tmp2(buff2,sizeof(buff2),cs);
|
||||
String tmp3(buff3,sizeof(buff3),cs);
|
||||
extra.length(0);
|
||||
tmp1.length(0);
|
||||
tmp2.length(0);
|
||||
tmp3.length(0);
|
||||
|
||||
quick_type= -1;
|
||||
item_list.empty();
|
||||
item_list.push_back(new Item_int((int32)
|
||||
join->select_lex->select_number));
|
||||
|
@ -10165,7 +10168,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||
else
|
||||
item_list.push_back(item_null);
|
||||
|
||||
/* Build key,key_len, and ref values and add them to item_list */
|
||||
/* Build "key", "key_len", and "ref" values and add them to item_list */
|
||||
if (tab->ref.key_parts)
|
||||
{
|
||||
KEY *key_info=table->key_info+ tab->ref.key;
|
||||
|
@ -10200,7 +10203,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||
}
|
||||
else if (tab->select && tab->select->quick)
|
||||
{
|
||||
tab->select->quick->fill_keys_and_lengths(&tmp2, &tmp3);
|
||||
tab->select->quick->add_keys_and_lengths(&tmp2, &tmp3);
|
||||
item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length(),cs));
|
||||
item_list.push_back(new Item_string(tmp3.ptr(),tmp3.length(),cs));
|
||||
item_list.push_back(item_null);
|
||||
|
@ -10211,9 +10214,11 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||
item_list.push_back(item_null);
|
||||
item_list.push_back(item_null);
|
||||
}
|
||||
/* Add "rows" field to item_list. */
|
||||
item_list.push_back(new Item_int((longlong) (ulonglong)
|
||||
join->best_positions[i]. records_read,
|
||||
21));
|
||||
/* Build "Extra" field and add it to item_list. */
|
||||
my_bool key_read=table->key_read;
|
||||
if (tab->type == JT_NEXT && table->used_keys.is_set(tab->index))
|
||||
key_read=1;
|
||||
|
@ -10225,38 +10230,51 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||
item_list.push_back(new Item_string(tab->info,strlen(tab->info),cs));
|
||||
else
|
||||
{
|
||||
if (quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE)
|
||||
{
|
||||
extra.append("; Using ");
|
||||
tab->select->quick->add_info_string(&extra);
|
||||
}
|
||||
if (tab->select)
|
||||
{
|
||||
if (tab->use_quick == 2)
|
||||
{
|
||||
char buf[MAX_KEY/8+1];
|
||||
sprintf(buff_ptr,"; Range checked for each record (index map: 0x%s)",
|
||||
tab->keys.print(buf));
|
||||
buff_ptr=strend(buff_ptr);
|
||||
extra.append("; Range checked for each record (index map: 0x");
|
||||
extra.append(tab->keys.print(buf));
|
||||
extra.append(')');
|
||||
}
|
||||
else
|
||||
buff_ptr=strmov(buff_ptr,"; Using where");
|
||||
extra.append("; Using where");
|
||||
}
|
||||
if (key_read)
|
||||
buff_ptr= strmov(buff_ptr,"; Using index");
|
||||
extra.append("; Using index");
|
||||
if (table->reginfo.not_exists_optimize)
|
||||
buff_ptr= strmov(buff_ptr,"; Not exists");
|
||||
extra.append("; Not exists");
|
||||
if (need_tmp_table)
|
||||
{
|
||||
need_tmp_table=0;
|
||||
buff_ptr= strmov(buff_ptr,"; Using temporary");
|
||||
extra.append("; Using temporary");
|
||||
}
|
||||
if (need_order)
|
||||
{
|
||||
need_order=0;
|
||||
buff_ptr= strmov(buff_ptr,"; Using filesort");
|
||||
extra.append("; Using filesort");
|
||||
}
|
||||
if (distinct & test_all_bits(used_tables,thd->used_tables))
|
||||
buff_ptr= strmov(buff_ptr,"; Distinct");
|
||||
if (buff_ptr == buff)
|
||||
buff_ptr+= 2; // Skip inital "; "
|
||||
item_list.push_back(new Item_string(buff+2,(uint) (buff_ptr - buff)-2,
|
||||
cs));
|
||||
extra.append("; Distinct");
|
||||
|
||||
/* Skip initial "; "*/
|
||||
const char *str= extra.ptr();
|
||||
uint32 len= extra.length();
|
||||
if (len)
|
||||
{
|
||||
str += 2;
|
||||
len -= 2;
|
||||
}
|
||||
item_list.push_back(new Item_string(str, len, cs));
|
||||
}
|
||||
// For next iteration
|
||||
used_tables|=table->map;
|
||||
|
|
Loading…
Reference in a new issue