文章目录
- [1、insert 优化](#1、insert 优化)
- 2、主键优化
- [3、order by 优化](#3、order by 优化)
- [4、group by 优化](#4、group by 优化)
- [5、limit 优化](#5、limit 优化)
- [6、count 优化](#6、count 优化)
- [7、update 优化](#7、update 优化)
1、insert 优化
insert:批量插入、手动控制事务、主键顺序插入
大批量插入:load data local infile
2、主键优化
主键长度尽量短、顺序插入 auto_increment
3、order by 优化
using index:直接通过索引返回数据,性能高
using filesort:需要将返回的结果在排序缓冲区排序
4、group by 优化
索引,多字段分组满足最左前缀法则
5、limit 优化
覆盖索引 + 子查询
6、count 优化
性能:count(字段)< count(主键id)< count(1)约等于 count(*)
7、update 优化
尽量根据主键/索引字段进行数据更新