1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

branches/zip: innodb-index.result: Adapt the results to a patch from MySQL.

Unfortunately, the patch seems to prevent MySQL from utilizing secondary
indexes in the ORDER BY clauses.  Thus, the test no longer checks if newly
created indexes are well-formed.

ChangeSet@1.2528.98.1  2007-08-02 12:45:56-07:00  igor@mysql.com

Fixed bug#28404.
This patch adds cost estimation for the queries with ORDER BY / GROUP BY
and LIMIT. 
If there was a ref/range access to the table whose rows were required
to be ordered in the result set the optimizer always employed this access
though a scan by a different index that was compatible with the required 
order could be cheaper to produce the first L rows of the result set.
Now for such queries the optimizer makes a choice between the cheapest
ref/range accesses not compatible with the given order and index scans
compatible with it.
This commit is contained in:
marko
2007-10-08 12:16:32 +00:00
parent bfc48819c5
commit dcde0edf82

View File

@@ -17,7 +17,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
explain select * from t1 order by d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL d2 23 NULL 4
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
select * from t1 order by d;
a b c d
3 4 ad ad
@@ -104,7 +104,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 10 NULL 4
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
select * from t1 order by c;
a b c d
3 4 ad ad
@@ -156,13 +156,13 @@ a b c d
4 4 tr tr
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 5 NULL 5
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 10 NULL 5
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
explain select * from t1 order by d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL d2 23 NULL 5
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -341,7 +341,7 @@ a b c d
8 9 fff fff
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 16 NULL 5
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
@@ -394,7 +394,7 @@ a b c d
11 11 kkk kkk
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 16 NULL 6
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
@@ -452,10 +452,10 @@ a b c d
11 11 kkk kkk
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 16 NULL 7
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using filesort
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 34 NULL 7
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using filesort
explain select * from t1 order by d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using filesort
@@ -639,7 +639,7 @@ a b c d
10 10 kkk iii
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 5 NULL 6
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
@@ -696,13 +696,13 @@ a b c d
11 11 aaa mmm
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 5 NULL 7
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using filesort
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 31 NULL 7
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using filesort
explain select * from t1 order by d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL d 63 NULL 7
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using filesort
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -766,7 +766,7 @@ a b c d
8 9 fff fff
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 5 NULL 5
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
@@ -819,13 +819,13 @@ a b c d
10 10 aaa kkk
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 5 NULL 6
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 21 NULL 6
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
explain select * from t1 order by d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL d 43 NULL 6
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -914,13 +914,13 @@ Table Op Msg_type Msg_text
test.t1 check status OK
explain select * from t1 order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c 5 NULL 9
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
explain select * from t1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 9
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 4 NULL 9
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
select * from t1 order by a;
a b c
1 5 1