想知道是否有人可以帮助我更好地优化这个查询,因为它需要大约 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
- 折扣.start_date
- 零售商关闭
- discount.only_for