加入收藏 | 设为首页 | 会员中心 | 我要投稿 厦门站长网 (https://www.0592zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

mysql索引设置查询

发布时间:2021-02-10 10:04:32 所属栏目:MySql教程 来源:网络整理
导读:我必须为这样的查询设置哪些索引?谢谢 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' I

我必须为这样的查询设置哪些索引?谢谢

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子句中的列以及在其上执行连接的列.

对于特定查询,您可能要参考查询的说明计划.它将向您展示MySQL如何执行查询,因此可以相应地设置索引:http://dev.mysql.com/doc/refman/5.0/en/explain.html

(编辑:厦门站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读