MySQL查询耗时138秒,求优化及EXPLAIN结果解读
查询性能优化求助:大表关联查询耗时过长
product_sub_locations表共701269条数据- 已为所有关联字段添加索引,但查询仍耗时138秒
查询语句
EXPLAIN SELECT P.sku, PL.name, L.name, SUM(PSL.qty) as total_qty FROM product_sub_locations PSL INNER JOIN products P ON P.id = PSL.product_id INNER JOIN categories C ON C.id = P.category_id AND C.is_finish_good = 1 INNER JOIN sub_locations SL ON SL.id = PSL.sub_location_id INNER JOIN locations L ON L.id = SL.location_id INNER JOIN locations PL ON PL.id = L.parent_location_id WHERE 1 = 1 GROUP BY P.id, L.id ORDER BY P.sku, PL.name, L.name
现有查询耗时日志截图及EXPLAIN执行计划截图,恳请帮忙解读EXPLAIN结果,并提供查询性能优化方案。
内容的提问来源于stack exchange,提问作者Hardeep Singh
相关产品推荐
相关产品推荐

