fhumanes 12/15/2023 | |
Hello, All database managers have the functionality of showing the data access plan, when you facilitate an SQL. Write an article to show this functionality in MySQL and using the free Mysql Workbench product: https://fhumanes.com/blog/guias-desarrollo/guia-12-phprunner-optimizar-accesos-a-mysql/ I have not analyzed the query that you have put, but the last line of "Left Join" makes no sense if you do not use the information in that table. In the "New Select" field, Join's information is not used. Another huge cost is the "distinct", since you do the entire cost of the curricle of all records and then keep a small set of these. That said with the "Explain Access" information you can analyze the costs. Greetings, |
Sergey Kornilov 12/15/2023 | |
I see two problems here.
DISTINCT will always be slow unless you create a compund index on all fields included in this query. I don't think this is possible at all as you have field coming from another table. You need to find a way to remove DISTINCT from this query.
|