I have below query that takes 7 secs to run
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'
when i run it second time it takes 160 ms. what wrong why it takes so long on 1st run on everytime
EXPLAIN:
| 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 |
| 1 | SIMPLE | BusinessesCategory | ref | PRIMARY,fk_businesses_has_categories_categories1_idx,fk_businesses_has_categorie_businesses_idx | fk_businesses_has_categories_categories1_idx | 4 | const | 49630 | Using where; Using index |
| 1 | SIMPLE | Business | eq_ref | PRIMARY | PRIMARY | 4 | yuldi.BusinessesCategory.business_id | 1 | Using index |