我从我的EXPLAIN查询中获得以下内容。我不知道如何使用它来改善我的查询性能。我的查询如下:想不通为什么MYSQL查询是如此之慢
SELECT
`b`.`business_name` AS `Name`,
`b`.`address` AS `Address`,
`b`.`city` AS `City`,
`b`.`phone_number` AS `Phone`,
`b`.`state` AS `Prov`,
`i`.`date` AS `Last_Observed`,
group_concat(`v`.`notes` separator ', ') AS `Notes`,
`v`.`critical` AS `Criticality`,
`i`.`type` AS `Inspection_Type`,
`i`.`rating` AS `Rating`
FROM (`fs_v1_violation_table` `v`
LEFT JOIN (`fs_v1_inspection_table` `i`
LEFT JOIN `fs_v1_business_table` `b` ON((`b`.`id` = `i`.`business_id`)))
ON((`i`.`id` = `v`.`inspection_id`)))
WHERE `v`.`type` = 'Cleanliness' AND (
b.city = 'North Vancouver'
OR b.city = 'Vancouver'
OR b.city = 'White Rock'
OR b.city = 'West Vancouver'
OR b.city = 'Burnaby'
OR b.city = 'Langley'
OR b.city = 'Maple Ridge'
OR b.city = 'Delta'
OR b.city = 'Surrey')
GROUP BY `i`.`id`
ORDER BY `i`.`date` desc;
任何想法,我可能会寻求提高性能?查询需要约3分钟。
尝试EXPLAIN:https://dev.mysql.com/doc/refman/5.7/en/explain.html –
使用'explain'方法检查。 – urfusion
尝试在b.city上创建索引 –