我有一個疑問,這是我的表: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!有誰能告訴我爲什麼?複合鑰匙訂單有什麼問題?