mysql 5.6 inner join查询慢的优化方案

SELECT
DISTINCT Bus_CompleteList.WXOpenId, Bus_UserList.WXNickName
FROM
Bus_CompleteList
inner join Bus_UserList on Bus_UserList.WXOpenId=Bus_CompleteList.WXOpenId
ORDER BY Bus_CompleteList.CreateTime DESC LIMIT 0,10

将inner join 后续的SQL语句变成子查询

SELECT
AR.WXOpenId, Bus_UserList.WXNickName
FROM
(select DISTINCT WXOpenId from Bus_CompleteList ORDER BY CreateTime DESC LIMIT 0,10) AR
inner join Bus_UserList on Bus_UserList.WXOpenId=AR.WXOpenId

 

posted @ 2022-11-23 01:06  DerekHan  阅读(653)  评论(0编辑  收藏  举报