用show processlist发现卡在Sorting result

用show processlist发现卡在Sorting result

现像:

其他命令都被locked,等待Sorting result,求解?

772 | root | 209.200.10.79:54146 | smf | Query | 395 | Locked | SELECT ID_MSG, icon, subject, posterTime, posterIP, ID_MEMBER, modifiedTime, modifiedName, body

775 | root | 209.200.10.79:54157 | smf | Query | 397 | Sorting result | SELECT t.ID_TOPIC, t.numReplies, t.locked, t.numViews, t.isSticky, t.ID_POLL,0 AS new_from

原因:某条sql语句执行时间太长,导致表被锁定,而此刻又有许多sql任务在排队等待操作该表,最后越积越多,导致卡死

解决:查看该sql语句在哪个文件里,优化一下该语句