作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的mysql查询如下,我需要创建索引来提高结果获取。
SELECT * FROM tbl_name
WHERE seasonid = 1 AND status = 'N'
AND month = 10 AND (team_a = 'India' OR team_b = 'India');
提前致谢
最佳答案
(a = 1 OR a = 3)
转换为 a IN (1,3)
,有时是可以优化的。但是,你没有这种情况。因此,OR
两侧的表达式对于索引来说是无用的。
INDEX(seasonid,status,month)
具有任意顺序的 3 个字段是该查询的“最佳”索引。
另请参阅我的 index cookbook .
关于mysql - 当where条件由 'AND'和 'OR'组合组成时,mysql应该创建什么索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34082557/
我是一名优秀的程序员,十分优秀!