Mysql嵌套查询与连接查询的效率问题
www.比较.htmlwwwcountandmysqlblogwhere
执行语句如下:select count(DISTINCT l1) from t1 where l1 in(select l2 from t2 where l3=‘xxx‘) 感觉速度很慢(几十秒),
但是单独执行子查询select l2 from t2 where l3=‘xxx‘或者去掉子查询这个直接执行select count(DISTINCT l1) from t1都比较快。
将语句改成join的形式效果就快很多(毫秒级别),修改后语句如下:selectcount(DISTINCT l1) from t1 inner join t2 where t1.l1=t2.l2 and t2.l3=‘xxx‘。
具体原因分析可见:/Bccd/p/6607515.html
Mysql嵌套查询与连接查询的效率问题
www.比较.htmlwwwcountandmysqlblogwhere
原文:/bigbitcoin/p/7845729.html
来源: /infodetail-2397334.html