MySQL slow query using filesort

后端 未结 3 1672
故里飘歌
故里飘歌 2021-01-27 17:57

I have speed problems with a MySQL query. The tables definitions are as follows:

CREATE TABLE IF NOT EXISTS `student` (
  `student_id` int(11) unsigned NOT NULL          


        
3条回答
  •  北海茫月
    2021-01-27 18:38

    Try index:

    KEY student_sort(countup DESC ,updated_time DESC)
    

    Then use STRAIGHT_JOIN and FORCE INDEX:

    SELECT *
    FROM student force index(student_sort) STRAIGHT_JOIN 
         college 
             ON student.student_college = college.college_id
    WHERE college_location = 1
    ORDER BY student.countup desc, 
             student.updated_time desc
    LIMIT 15;
    

提交回复
热议问题