Commit 6c9bfe78 authored by marko's avatar marko

branches/zip: innodb-index.test: Add FORCE INDEX directives and remove

those SELECTs whose ORDER BY cannot possibly make use of an index.
parent 2561797b
......@@ -15,10 +15,10 @@ t1 CREATE TABLE `t1` (
`d` varchar(20) DEFAULT NULL,
KEY `d2` (`d`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
explain select * from t1 order by d;
explain select * from t1 force index(d2) order by d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
select * from t1 order by d;
1 SIMPLE t1 index NULL d2 23 NULL 4
select * from t1 force index (d2) order by d;
a b c d
3 4 ad ad
2 3 ak ak
......@@ -66,7 +66,7 @@ t1 CREATE TABLE `t1` (
KEY `b` (`b`),
KEY `d` (`d`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
explain select * from t1 order by c;
explain select * from t1 force index(c) 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
drop index c on t1;
......@@ -102,10 +102,10 @@ t1 CREATE TABLE `t1` (
KEY `b` (`b`),
KEY `d` (`d`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
explain select * from t1 order by c;
explain select * from t1 force index(c) order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
select * from t1 order by c;
1 SIMPLE t1 index NULL c 10 NULL 4
select * from t1 force index(c) order by c;
a b c d
3 4 ad ad
2 3 ak ak
......@@ -133,36 +133,36 @@ a b c d
4 4 tr tr
5 5 oo oo
6 1 ggg ggg
select * from t1 order by b;
select * from t1 force index(b) order by b;
a b c d
6 1 ggg ggg
2 3 ak ak
3 4 ad ad
4 4 tr tr
5 5 oo oo
select * from t1 order by c;
select * from t1 force index(c) order by c;
a b c d
3 4 ad ad
2 3 ak ak
6 1 ggg ggg
5 5 oo oo
4 4 tr tr
select * from t1 order by d;
select * from t1 force index(d) order by d;
a b c d
3 4 ad ad
2 3 ak ak
6 1 ggg ggg
5 5 oo oo
4 4 tr tr
explain select * from t1 order by b;
explain select * from t1 force index(b) order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
explain select * from t1 order by c;
1 SIMPLE t1 index NULL b 5 NULL 5
explain select * from t1 force index(c) 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
explain select * from t1 order by d;
1 SIMPLE t1 index NULL c 10 NULL 5
explain select * from t1 force index(d) order by d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
1 SIMPLE t1 index NULL d 23 NULL 5
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -211,21 +211,14 @@ a b c d
3 3 ad ad
4 4 afe afe
5 1 ggg ggg
select * from t1 order by b;
a b c d
1 1 ab ab
5 1 ggg ggg
2 2 ac ac
3 3 ad ad
4 4 afe afe
select * from t1 order by c;
select * from t1 force index(c) order by c;
a b c d
1 1 ab ab
2 2 ac ac
3 3 ad ad
4 4 afe afe
5 1 ggg ggg
select * from t1 order by d;
select * from t1 force index(d) order by d;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -235,10 +228,10 @@ a b c d
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
explain select * from t1 order by c;
explain select * from t1 force index(c) 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
explain select * from t1 order by d;
explain select * from t1 force index(d) order by d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
show create table t1;
......@@ -262,23 +255,7 @@ a b c d
4 4 afe afe
5 1 ggg ggg
8 9 fff fff
select * from t1 order by b;
a b c d
1 1 ab ab
5 1 ggg ggg
2 2 ac ac
3 3 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by c;
a b c d
1 1 ab ab
2 2 ac ac
3 3 ad ad
4 4 afe afe
8 9 fff fff
5 1 ggg ggg
select * from t1 order by d;
select * from t1 force index(c) order by c;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -289,7 +266,7 @@ a b c d
explain select * from t1 order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
explain select * from t1 order by c;
explain select * from t1 force index(c) 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
explain select * from t1 order by d;
......@@ -318,36 +295,16 @@ a b c d
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by b;
select * from t1 force index(b) order by b;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by c;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by d;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
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 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
explain select * from t1 order by d;
explain select * from t1 force index(b) order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
1 SIMPLE t1 index NULL b 16 NULL 5
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -368,23 +325,7 @@ a b c d
4 4 afe afe
8 9 fff fff
11 11 kkk kkk
select * from t1 order by b;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
11 11 kkk kkk
select * from t1 order by c;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
11 11 kkk kkk
select * from t1 order by d;
select * from t1 force index(b) order by b;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -392,15 +333,9 @@ a b c d
4 4 afe afe
8 9 fff fff
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 ALL NULL NULL NULL NULL 6 Using filesort
explain select * from t1 order by c;
explain select * from t1 force index(b) order by b;
id select_type table type possible_keys key key_len ref rows Extra
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 ALL NULL NULL NULL NULL 6 Using filesort
1 SIMPLE t1 index NULL b 16 NULL 6
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -423,7 +358,7 @@ a b c d
8 9 fff fff
11 11 kkk kkk
13 13 yyy aaa
select * from t1 order by b;
select * from t1 force index(b) order by b;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -432,7 +367,7 @@ a b c d
8 9 fff fff
11 11 kkk kkk
13 13 yyy aaa
select * from t1 order by c;
select * from t1 force index(c) order by c;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -441,24 +376,12 @@ a b c d
8 9 fff fff
11 11 kkk kkk
13 13 yyy aaa
select * from t1 order by d;
a b c d
13 13 yyy aaa
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
11 11 kkk kkk
explain select * from t1 order by b;
explain select * from t1 force index(b) order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using filesort
explain select * from t1 order by c;
1 SIMPLE t1 index NULL b 16 NULL 7
explain select * from t1 force index(c) order by c;
id select_type table type possible_keys key key_len ref rows Extra
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
1 SIMPLE t1 index NULL c 34 NULL 7
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -564,36 +487,6 @@ a b c d
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by b;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by c;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by d;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
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 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
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 5 Using filesort
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -613,23 +506,7 @@ a b c d
4 4 afe afe
8 9 fff fff
10 10 kkk iii
select * from t1 order by b;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
10 10 kkk iii
select * from t1 order by c;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
10 10 kkk iii
select * from t1 order by d;
select * from t1 force index(b) order by b;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -637,15 +514,9 @@ a b c d
4 4 afe afe
8 9 fff fff
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 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
explain select * from t1 order by d;
explain select * from t1 force index(b) order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
1 SIMPLE t1 index NULL b 5 NULL 6
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -667,7 +538,7 @@ a b c d
8 9 fff fff
10 10 kkk iii
11 11 aaa mmm
select * from t1 order by b;
select * from t1 force index(b) order by b;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -676,7 +547,7 @@ a b c d
8 9 fff fff
10 10 kkk iii
11 11 aaa mmm
select * from t1 order by c;
select * from t1 force index(c) order by c;
a b c d
11 11 aaa mmm
1 1 ab ab
......@@ -685,7 +556,7 @@ a b c d
4 4 afe afe
8 9 fff fff
10 10 kkk iii
select * from t1 order by d;
select * from t1 force index(d) order by d;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -694,15 +565,15 @@ a b c d
8 9 fff fff
10 10 kkk iii
11 11 aaa mmm
explain select * from t1 order by b;
explain select * from t1 force index(b) order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using filesort
explain select * from t1 order by c;
1 SIMPLE t1 index NULL b 5 NULL 7
explain select * from t1 force index(c) order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using filesort
explain select * from t1 order by d;
1 SIMPLE t1 index NULL c 31 NULL 7
explain select * from t1 force index(d) 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
1 SIMPLE t1 index NULL d 63 NULL 7
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -743,36 +614,16 @@ a b c d
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by b;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by c;
select * from t1 force index(b) order by b;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by d;
a b c d
1 1 ab ab
2 2 ac ac
3 2 ad ad
4 4 afe afe
8 9 fff fff
explain select * from t1 order by b;
explain select * from t1 force index(b) order by b;
id select_type table type possible_keys key key_len ref rows Extra
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
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 5 Using filesort
1 SIMPLE t1 index NULL b 5 NULL 5
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -793,7 +644,7 @@ a b c d
4 4 afe afe
8 9 fff fff
10 10 aaa kkk
select * from t1 order by b;
select * from t1 force index(b) order by b;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -801,7 +652,7 @@ a b c d
4 4 afe afe
8 9 fff fff
10 10 aaa kkk
select * from t1 order by c;
select * from t1 force index(c) order by c;
a b c d
10 10 aaa kkk
1 1 ab ab
......@@ -809,7 +660,7 @@ a b c d
3 2 ad ad
4 4 afe afe
8 9 fff fff
select * from t1 order by d;
select * from t1 force index(d) order by d;
a b c d
1 1 ab ab
2 2 ac ac
......@@ -817,15 +668,15 @@ a b c d
4 4 afe afe
8 9 fff fff
10 10 aaa kkk
explain select * from t1 order by b;
explain select * from t1 force index(b) order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
explain select * from t1 order by c;
1 SIMPLE t1 index NULL b 5 NULL 6
explain select * from t1 force index(c) 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
explain select * from t1 order by d;
1 SIMPLE t1 index NULL c 21 NULL 6
explain select * from t1 force index(d) order by d;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
1 SIMPLE t1 index NULL d 43 NULL 6
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -912,15 +763,15 @@ t1 CREATE TABLE `t1` (
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
explain select * from t1 order by c;
explain select * from t1 force index(c) order by c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
1 SIMPLE t1 index NULL c 5 NULL 9
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;
explain select * from t1 force index(b) order by b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
1 SIMPLE t1 index NULL b 4 NULL 9
select * from t1 order by a;
a b c
1 5 1
......@@ -932,7 +783,7 @@ a b c
11 19 19
12 18 18
13 17 17
select * from t1 order by b;
select * from t1 force index(b) order by b;
a b c
5 1 5
4 2 4
......@@ -943,7 +794,7 @@ a b c
12 18 18
11 19 19
10 20 20
select * from t1 order by c;
select * from t1 force index(c) order by c;
a b c
1 5 1
2 4 2
......
......@@ -9,15 +9,15 @@ alter table t1 add index b (b), add index b (b);
alter table t1 add index (b,b);
alter table t1 add index d2 (d);
show create table t1;
explain select * from t1 order by d;
select * from t1 order by d;
explain select * from t1 force index(d2) order by d;
select * from t1 force index (d2) order by d;
--error ER_DUP_ENTRY
alter table t1 add unique index (b);
show create table t1;
alter table t1 add index (b);
show create table t1;
-- Check how existing tables interfere with temporary tables.
# Check how existing tables interfere with temporary tables.
CREATE TABLE `t1#1`(a INT PRIMARY KEY) ENGINE=InnoDB;
--error 156
......@@ -29,7 +29,7 @@ drop table `t1#2`;
alter table t1 add unique index (c), add index (d);
show create table t1;
explain select * from t1 order by c;
explain select * from t1 force index(c) order by c;
--error ER_REQUIRES_PRIMARY_KEY
drop index c on t1;
alter table t1 add primary key (a), drop index c;
......@@ -40,18 +40,18 @@ alter table t1 add primary key (c);
alter table t1 drop primary key, add primary key (b);
create unique index c on t1 (c);
show create table t1;
explain select * from t1 order by c;
select * from t1 order by c;
explain select * from t1 force index(c) order by c;
select * from t1 force index(c) order by c;
alter table t1 drop index b, add index (b);
show create table t1;
insert into t1 values(6,1,'ggg','ggg');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
select * from t1 force index(b) order by b;
select * from t1 force index(c) order by c;
select * from t1 force index(d) order by d;
explain select * from t1 force index(b) order by b;
explain select * from t1 force index(c) order by c;
explain select * from t1 force index(d) order by d;
show create table t1;
drop table t1;
......@@ -64,21 +64,18 @@ alter table t1 add unique index (d(10));
show create table t1;
insert into t1 values(5,1,'ggg','ggg');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
select * from t1 force index(c) order by c;
select * from t1 force index(d) order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
explain select * from t1 force index(c) order by c;
explain select * from t1 force index(d) order by d;
show create table t1;
alter table t1 drop index d;
insert into t1 values(8,9,'fff','fff');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
select * from t1 force index(c) order by c;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 force index(c) order by c;
explain select * from t1 order by d;
show create table t1;
drop table t1;
......@@ -89,32 +86,22 @@ commit;
alter table t1 add unique index (b,c);
insert into t1 values(8,9,'fff','fff');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
select * from t1 force index(b) order by b;
explain select * from t1 force index(b) order by b;
show create table t1;
alter table t1 add index (b,c);
insert into t1 values(11,11,'kkk','kkk');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
select * from t1 force index(b) order by b;
explain select * from t1 force index(b) order by b;
show create table t1;
alter table t1 add unique index (c,d);
insert into t1 values(13,13,'yyy','aaa');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
select * from t1 force index(b) order by b;
select * from t1 force index(c) order by c;
explain select * from t1 force index(b) order by b;
explain select * from t1 force index(c) order by c;
show create table t1;
drop table t1;
......@@ -135,10 +122,10 @@ alter table t4 drop index d;
alter table t2 drop index b;
--error ER_DROP_INDEX_FK
alter table t2 drop index b, drop index c, drop index d;
-- Apparently, the following makes mysql_alter_table() drop index d.
# Apparently, the following makes mysql_alter_table() drop index d.
create unique index dc on t2 (d,c);
create index dc on t1 (b,c);
-- This should preserve the foreign key constraints.
# This should preserve the foreign key constraints.
alter table t2 add primary key (a);
insert into t1 values (1,1,1);
insert into t3 values (1,1,1);
......@@ -148,7 +135,7 @@ commit;
alter table t4 add constraint dc foreign key (a) references t1(a);
show create table t4;
--replace_regex /'test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
# a foreign key 'test/dc' already exists
--error ER_CANT_CREATE_TABLE
alter table t3 add constraint dc foreign key (a) references t1(a);
show create table t3;
......@@ -158,7 +145,7 @@ show create table t2;
delete from t1;
--error ER_CANT_DROP_FIELD_OR_KEY
drop index dc on t4;
-- there is no foreign key dc on t3
# there is no foreign key dc on t3
--replace_regex /'\.\/test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/
--error ER_ERROR_ON_RENAME
alter table t3 drop foreign key dc;
......@@ -177,32 +164,22 @@ commit;
alter table t1 add unique index (b);
insert into t1 values(8,9,'fff','fff');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
show create table t1;
alter table t1 add index (b);
insert into t1 values(10,10,'kkk','iii');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
select * from t1 force index(b) order by b;
explain select * from t1 force index(b) order by b;
show create table t1;
alter table t1 add unique index (c), add index (d);
insert into t1 values(11,11,'aaa','mmm');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
select * from t1 force index(b) order by b;
select * from t1 force index(c) order by c;
select * from t1 force index(d) order by d;
explain select * from t1 force index(b) order by b;
explain select * from t1 force index(c) order by c;
explain select * from t1 force index(d) order by d;
show create table t1;
check table t1;
drop table t1;
......@@ -217,22 +194,18 @@ show create table t1;
alter table t1 add index (b);
insert into t1 values(8,9,'fff','fff');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
select * from t1 force index(b) order by b;
explain select * from t1 force index(b) order by b;
show create table t1;
alter table t1 add unique index (c), add index (d);
insert into t1 values(10,10,'aaa','kkk');
select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
select * from t1 force index(b) order by b;
select * from t1 force index(c) order by c;
select * from t1 force index(d) order by d;
explain select * from t1 force index(b) order by b;
explain select * from t1 force index(c) order by c;
explain select * from t1 force index(d) order by d;
show create table t1;
check table t1;
drop table t1;
......@@ -273,12 +246,12 @@ alter table t1 add unique index (b);
insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17);
show create table t1;
check table t1;
explain select * from t1 order by c;
explain select * from t1 force index(c) order by c;
explain select * from t1 order by a;
explain select * from t1 order by b;
explain select * from t1 force index(b) order by b;
select * from t1 order by a;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 force index(b) order by b;
select * from t1 force index(c) order by c;
drop table t1;
create table t1(a int not null, b int not null) engine=innodb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment