天天百科

where条件字段可以设置索引吗

2023-08-08 分类:百科

TIPS:本文共有 507 个字,阅读大概需要 2 分钟。

假设有组合索引 index(a,b,c),以下情况不考虑 select * 内容 (覆盖索引)

where a = 3 用到索引 a

where a = 3 and b = 3 用到索引 a,b

where a = 3 and b = 4 and c = 5 用到索引 a,b,c

where b = 3 或者 where b = 3 and c = 4 或者 where c = 4 索引失效

where a = 3 and c = 5 用到索引 a

where a = 3 and b > 4 and c = 5 用到索引a和b,c不能用在范围之后

where a = 3 and b like 'kk%' and c = 4 用到索引a,b,c。

where a = 3 and b like '%kk' and c = 4 使用到 a

where a = 3 and b like '%kk%' and c = 4 用到 a

where a = 3 and b like 'k%kk%' and c = 4 用到a,b,c

切记使用索引字段值的类型必须匹配,否则索引无效。

如果觉得《where条件字段可以设置索引吗》对你有帮助,请点赞、收藏,并留下你的观点哦!

阅读剩余内容
网友评论
相关阅读
小编推荐