実行に約4秒かかるため、誰かがこのクエリをより適切に最適化するのを手伝ってくれるかどうか疑問に思っています.
SELECT discount.*, retailer.name AS retailer_name,
sub_category.type AS subcategory_type
FROM discount
JOIN retailer ON retailer.id = discount.retailer
JOIN sub_category ON sub_category.id = discount.sub_category
WHERE discount.start_date <= 1348133607
AND retailer.closed = 0
AND ( discount.only_for = 'PROC' OR discount.only_for = '' )
ORDER BY discount.updated_on DESC LIMIT 25
私はインデックスを持っています:
- 割引小売業者
- 割引.sub_category
- 割引.開始日
- 小売業者.閉鎖
- discount.only_for