mysql in 子查询 效率慢,对比
Posted 鴻飛
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql in 子查询 效率慢,对比相关的知识,希望对你有一定的参考价值。
desc SELECT id,detail,groupId from hs_knowledge_point where groupId in ( SELECT groupId from hs_knowledge_point where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 UNION all SELECT groupId from hs_knowledge_point_commit where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 ) UNION ALL SELECT id,detail,groupId from hs_knowledge_point_commit where groupId in ( SELECT groupId from hs_knowledge_point where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 UNION all SELECT groupId from hs_knowledge_point_commit where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 )
SELECT id,detail,groupId from hs_knowledge_point where groupId in ( select groupId from ( SELECT groupId from hs_knowledge_point where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 UNION all SELECT groupId from hs_knowledge_point_commit where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 ) tmp ) UNION ALL SELECT id,detail,groupId from hs_knowledge_point_commit where groupId in ( select groupId from ( SELECT groupId from hs_knowledge_point where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 UNION all SELECT groupId from hs_knowledge_point_commit where groupId>0 GROUP BY groupId HAVING COUNT(groupId) > 1 ) tmp )
以上是关于mysql in 子查询 效率慢,对比的主要内容,如果未能解决你的问题,请参考以下文章
MySQL - SELECT WHERE field IN(子查询) - 为啥非常慢?