What are the efficiency effects of mysql after using subquery efficiency
This article will explain in detail what the efficiency impact is after the use of sub-query efficiency of mysql. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
MySQL subquery efficiency: the effect of using subquery [SELECT id, `name` FROM customer where id IN (select DISTINCT (customerid) from searchaccount] efficiency is 10 times.
The efficiency impact of mysql after using subquery
Just take advantage of id:
Explain SELECT * from customer where id in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, 16, 17, 18, 19, 20)
Results:
The subquery is used:
Explain SELECT id, `name` FROM customer where id IN (select DISTINCT (customerid) from searchaccount WHERE kfuid=126 AND iskf=1) LIMIT 20
Results:
No subqueries are needed to achieve the same effect:
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
Efficiency is a ten-fold effect.
On the use of mysql sub-query efficiency after what efficiency impact is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.