当我使用'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
索引:
如何更快地完成第一个查询?
Joery。