mysql子查詢效率:利用子查詢【SELECT id,`name` FROM customer where id IN(select DISTINCT(customerid) from searchaccount】效率是10倍率的影響。
mysql利用子查詢後的效率影響
#只是利用id:
explain SELECT * from customer where id in(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
結果:
利用了子查詢:explain SELECT id,`name` FROM customer where id IN(select DISTINCT(customerid) from searchaccount WHERE kfuid=126 AND iskf=1) LIMIT 20
#不用子查詢,達到相同的效果:
explain select DISTINCT(customerid) as id,c.name from searchaccount s LEFT JOIN customer c on s.customerid=c.id WHERE s.kfuid=126 AND s.iskf=1 limit 20
#效率是10倍率的影響。(影片)#########相關免費學習推薦:mysql教學
以上是mysql利用子查詢效率怎麼樣的詳細內容。更多資訊請關注PHP中文網其他相關文章!