Navigation Menu

Skip to content

Commit

Permalink
multiple-column-index: Use target type as the first column.
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Feb 26, 2012
1 parent 0143a3d commit 5bd50ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Expand Up @@ -4,7 +4,7 @@ create table scores (
id int primary key auto_increment not null,
name char(30) not null,
score int not null,
index property (name, score)
index property (score, name)
) default charset utf8;
show create table scores;
Table Create Table
Expand All @@ -13,7 +13,7 @@ scores CREATE TABLE `scores` (
`name` char(30) NOT NULL,
`score` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `property` (`name`,`score`)
KEY `property` (`score`,`name`)
) ENGINE=mroonga DEFAULT CHARSET=utf8
insert into scores (name, score) values("Taro Yamada", 29);
insert into scores (name, score) values("Taro Yamada", -12);
Expand All @@ -25,15 +25,13 @@ id name score
2 Taro Yamada -12
3 Jiro Yamada 27
4 Taro Yamada 10
select * from scores where name = "Taro Yamada";
select * from scores where score = 29;
id name score
2 Taro Yamada -12
4 Taro Yamada 10
1 Taro Yamada 29
select * from scores where name = "Taro Yamada" and score = 29;
select * from scores where score = 29 and name = "Taro Yamada";
id name score
1 Taro Yamada 29
select * from scores where name = "Taro Yamada" and (score >= -12 and score < 29);
select * from scores where (score >= -12 and score < 29) and name = "Taro Yamada";
id name score
2 Taro Yamada -12
4 Taro Yamada 10
Expand Down
Expand Up @@ -25,17 +25,17 @@ create table scores (
id int primary key auto_increment not null,
name char(30) not null,
score int not null,
index property (name, score)
index property (score, name)
) default charset utf8;
show create table scores;
insert into scores (name, score) values("Taro Yamada", 29);
insert into scores (name, score) values("Taro Yamada", -12);
insert into scores (name, score) values("Jiro Yamada", 27);
insert into scores (name, score) values("Taro Yamada", 10);
select * from scores;
select * from scores where name = "Taro Yamada";
select * from scores where name = "Taro Yamada" and score = 29;
select * from scores where name = "Taro Yamada" and (score >= -12 and score < 29);
select * from scores where score = 29;
select * from scores where score = 29 and name = "Taro Yamada";
select * from scores where (score >= -12 and score < 29) and name = "Taro Yamada";
drop table scores;

--source include/have_mroonga_deinit.inc

0 comments on commit 5bd50ed

Please sign in to comment.