标题: 同时使用order by和limit有时候返回错误的结果集的奇怪问题 [打印本页] 作者: yj1804 时间: 2008-09-25 14:30 标题: 同时使用order by和limit有时候返回错误的结果集的奇怪问题 查询语句和结果如下:
mysql> SELECT * FROM ACE_URL_2008092417 WHERE CREATE_TIME >= 1222246800 AND CREATE_TIME <= 1222250399 AND IP_LOCAL = 3232249376 AND MAIN_URL LIKE 'http%' ORDER BY CREATE_TIME DESC limit 10000;
Empty set (0.00 sec)
mysql> select count(1) from ACE_URL_2008092417;
+----------+
| count(1) |
+----------+
| 20024977 |
+----------+
1 row in set (0.00 sec)
mysql> select count(1) from ACE_URL_2008092417 WHERE CREATE_TIME >= 1222246800 AND CREATE_TIME <= 1222250399 AND IP_LOCAL = 3232249376 AND MAIN_URL LIKE 'http%';
+----------+
| count(1) |
+----------+
| 2507612 |
+----------+
1 row in set (1 min 27.69 sec)
[ 本帖最后由 yj1804 于 2008-9-25 16:21 编辑 ]作者: yj1804 时间: 2008-09-25 16:41
* When using indexed ORDER BY sorting, incorrect query results
could be produced if the optimizer switched from a covering
index to a non-covering index.
(Bug#37548: http://bugs.mysql.com/37548)