How to avoid “Using temporary” in many-to-many queries?

前端 未结 4 633
悲&欢浪女
悲&欢浪女 2020-12-02 01:03

This query is very simple, all I want to do, is get all the articles in given category ordered by last_updated field:

SELECT
    `articles`.*
FR         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 01:48

    You should be able to avoid filesort by adding a key on articles.last_updated. MySQL needs the filesort for the ORDER BY operation, but can do it without filesort as long as you order by an indexed column (with some limitations).

    For much more info, see here: http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html

提交回复
热议问题