我怀疑,这是我的表:
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.9秒和1.68秒!谁能告诉我为什么?复合键顺序有什么问题?