desc和asc同时排序很慢

时间:2014-12-13 14:42:56

标签: mysql performance indexing sql-order-by

当我使用'ORDER BY datetime DESC和sticky ASC'同时查询速度很慢在forum_threads中有~200.000行。

+----+-------------+---------+---------+---------+--------+--------+---------+----------+
| id | category_id | user_id | subject | message | sticky | closed | deleted | datetime |
+----+-------------+---------+---------+---------+--------+--------+---------+----------+

此查询的速度为0.2秒(ORDER BY datetime DESC,sticky ASC)

SELECT * FROM forum_threads WHERE deleted = 0 ORDER BY datetime DESC, sticky ASC LIMIT 0, 30

此查询的速度为0.0008sec(ORDER BY datetime DESC)

SELECT * FROM forum_threads WHERE deleted = 0 ORDER BY datetime DESC, sticky ASC LIMIT 0, 30

索引: Indexes

如何更快地完成第一个查询?

Joery。

0 个答案:

没有答案