qq_MJX_0
2017-03-10 17:01
用in查询效率高吗
不高,用EXISTS替代IN、用NOT EXISTS替代NOT IN:
(高效)SELECT * FROM EMP (基础表) WHERE EMPNO > 0 AND EXISTS (SELECT ‘X' FROM DEPT WHERE DEPT.DEPTNO = EMP.DEPTNO AND LOC = ‘MELB')
(低效)SELECT * FROM EMP (基础表) WHERE EMPNO > 0 AND DEPTNO IN(SELECT DEPTNO FROM DEPT WHERE LOC = ‘MELB')
性能优化之MySQL优化
101639 学习 · 221 问题
相似问题