当前位置:网站首页>0730~Mysql优化
0730~Mysql优化
2022-07-31 07:42:00 【生活可真难啊】
常见的索引失效的原因?
1.使用了select*
2.没有保证最左前缀原则
3.模糊查询like左边不要加% -- 解决方案 覆盖索引查询
4.or关键字使用不当 -- 解决方案 使用union解决
5.查询条件中不能存在计算
6.查询条件中不能使用函数
7.order by 分组顺序和设置的索引不一致也会失效
8.varchar类型没有加单引号
9.使用is null 或者 is not null -- 如果设置属性不能为空,那么都不会走索引,
如果设置属性可以为空,那么is null 会走索引,is not null 不会走索引;
用EXPLAIN执行计划的时候,主要查看以下几个字段
type:查询的类型,起码要是ref,All是最坏的情况;
key:看实际命中了哪些索引;
rows:看查询语句查询的数量;
Extra:主要看UsingWhere表示用where条件过滤;
边栏推荐
猜你喜欢
随机推荐
CNN--各层的介绍
PowerCLi 一键批量部署OVA 到esxi 7
CNN--Introduction to each layer
2022.07.12 _ a day
Leetcode952. Calculate maximum component size by common factor
【Objective-C语言中的@property】
Yu Mr Series 】 【 2022 July 022 - Go Go teaching course of container in the dictionary
2022.07.13 _ a day
PHP中 比较 0、false、null,‘‘ “
关于@Autowired
MySQL安装教程
Tasks and task switching
shell/bash脚本命令教程
《opencv学习笔记》-- 仿射变换
NK-RTU980烧写裸机程序
LED flashing on CY7C68013A
Financial leasing business
【面试题】从输入URL到游览器渲染完成,经历了什么
Regarding "computing power", this article is worth reading
Read Elephant Swap in one article, why does it bring such a high premium to ePLATO?