我正在尝试调试MYSQL查询,因为它在一台服务器上花费大约4-5分钟,而在另一台MYSQL服务器上则失败。
查询是这样的:
SELECT
*,
TM.tutor_id as tutor_id,
TIMESTAMPDIFF( YEAR, birthdate, CURDATE( ) ) AS age
from
tutor_master as TM
LEFT JOIN category_master as CM
on TM.category = CM.category_id
LEFT JOIN tutor_expected_rate TER
ON FIND_IN_SET( TER.tutor_id, TM.tutor_id ) > 0
LEFT JOIN admin_shortlist_master SHM
ON TM.tutor_id = SHM.tutor_id
AND (SHM.user_auth_id = 'c84258e9c39059a89ab77d846ddab909')
INNER JOIN level_master LM
ON FIND_IN_SET(LM.level_id, TER.level_id) > 0
WHERE
1=1
GROUP BY
TM.tutor_id
order by
TM.is_priority DESC,
TM.tutor_id DESC
LIMIT
0, 10
和MYSQL解释结果是这样的:
1 SIMPLE TM NULL ALL PRIMARY,tutor_id NULL NULL NULL 27530 100.00 Using temporary; Using filesort
1 SIMPLE SHM NULL ref tutor_id,user_auth_id user_auth_id 257 const 1 100.00 Using where
1 SIMPLE CM NULL eq_ref PRIMARY PRIMARY 4 toprecru_portal_db.TM.category 1 100.00 NULL
1 SIMPLE LM NULL ALL NULL NULL NULL NULL 11 100.00 Using join buffer (Block Nested Loop)
1 SIMPLE TER NULL ALL NULL NULL NULL NULL 13223 100.00 Using where; Using join buffer (Block Nested Loop)
现在我的问题是,它有任何明显的错误,我忽略了使查询更有效率。 感谢。