我有一个疑问,这是我的表:MySQL的列顺序在复合键
mysql> show create table watchdog\G
*************************** 1. row ***************************
Table: watchdog
Create Table: CREATE TABLE `watchdog` (
`index1` int(11) NOT NULL DEFAULT '0',
`index2` int(11) NOT NULL DEFAULT '0',
`dog` int(11) NOT NULL DEFAULT '9',
PRIMARY KEY (`index1`,`index2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
< 1> 首先查询:
select index1, index2
from watchdog
where index1 > 4000008 and index1 < 4200007;
结果:
... | 4200001 | 4200002 | | 4200002 | 4200003 | | 4200003 | 4200004 | | 4200004 | 4200005 | | 4200005 | 4200006 | | 4200006 | 4200007 | +---------+---------+ 199997 rows in set (0.09 sec)
< 2> 第二个查询:
select index1, index2
from watchdog
where index2 > 4000009 and index2 < 4200007;
结果:
... | 4200002 | 4200003 | | 4200003 | 4200004 | | 4200004 | 4200005 | | 4200005 | 4200006 | +---------+---------+ 199997 rows in set (1.68 sec)
,他们所用的时间是0.9sec和1.68sec!有谁能告诉我为什么?复合钥匙订单有什么问题?