我有以下查询需要 7 秒才能运行
SELECT COUNT(*) AS `count`
FROM `yuldi`.`businesses` AS `Business`
LEFT JOIN `yuldi`.`businesses_categories` AS `BusinessesCategory`
ON (`Business`.`id` = `BusinessesCategory`.`business_id`)
LEFT JOIN `yuldi`.`categories` AS `Category`
ON (`BusinessesCategory`.`category_id` = `Category`.`id`)
WHERE `Category`.`slug` = 'building-construction'
Run Code Online (Sandbox Code Playgroud)
当我第二次运行它时需要 160 毫秒。为什么每次第一次运行都需要这么长时间
解释:
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
| 1 | SIMPLE | Category | const | PRIMARY,UNIQUE_SLUG,index_lug | UNIQUE_SLUG | 302 | const | 1 | Using index | …
Run Code Online (Sandbox Code Playgroud)