我必须为这样的查询设置哪些索引?谢谢
SELECT distinct event_dates.* FROM `event_dates`
INNER JOIN `events` ON `events`.id = `event_dates`.event_id
INNER JOIN `cores` ON `cores`.resource_id = `events`.id AND cores.resource_type = 'Event'
INNER JOIN `cores_kinds` ON `cores_kinds`.core_id = `cores`.id
INNER JOIN `kinds` ON `kinds`.id = `cores_kinds`.kind_id
WHERE (((super_kind_en IN ('party','cinema and theater'))
AND (day >= '2010-07-17' AND day <= '2010-08-16'))
AND (cores.searchable like '%p%'))
ORDER BY day,cores.vote desc LIMIT 0,30
最佳答案
一般的经验法则是在过滤结果集的列上有索引.换句话说,包含在WHERE子句中的列以及在其上执行连接的列.
@H_403_16@ 原文链接:https://www.f2er.com/mysql/532137.html对于特定查询,您可能要参考查询的说明计划.它将向您展示MysqL如何执行查询,因此可以相应地设置索引:http://dev.mysql.com/doc/refman/5.0/en/explain.html