当前位置:网站首页>MySQL优化小技巧
MySQL优化小技巧
2022-06-28 00:27:00 【明斯克开源】
max()
比如一个sql select max(money) from pay,当进行查询时会进行全表扫描查出最大值,但如果我们给 money加一个索引,执行效率就会很快,因为这相当于一个覆盖索引,索引是顺序的,不需要进行扫描查找
count()

count(*) 会将列为空的也计算进去,count(release_year),直接指定哪个字段则不会将为空的列计算进去
子查询优化
通常是将子查询转化为 join 来查询,但要注意数据重复的情况
limit 查询优化
limit通常还会伴随order by 排序,所以在进行order by 排序字段时最好用加索引的字段或者主键
索引优化
====
如何选择合适的列创建索引

离散度就是指该列的 《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》无偿开源 威信搜索公众号【编程进阶路】 不重复的值的多少,越多离散度越大,在联合索引中就应该放在前面
删除不用的索引和重复的索引
数据库表结构优化
========
选择合适的数据类型
范式化和反范式化优化

表垂直拆分

表水平拆分
水平拆分是为了解决单表数据量过大的问题,可以通过取模运算进行拆分,每个表的表结构是一样的,由此带来的问题就是查询和后台分析统计问题,可以统计时将表汇总统计,查询就应该考虑具体业务场景进行操作
系统配置文件优化
========
innodb_buffer_pool_size
边栏推荐
- Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
- 原理图合并中的技巧
- Numpy----np.reshape()
- Differences between cesium polygon extrudedheight and height
- [Yocto RM] 2 - Yocto Project Terms
- Domain Name System
- TI AM3352/54/59 工业核心板硬件说明书
- [sylixos] I2C device driver creation and use
- Anonymous Mount & named mount
- SQL injection bypass (2)
猜你喜欢

SQL 注入繞過(二)

Jenkins - Pipeline syntax

Jenkins - Pipeline 概念及创建方式

SQL injection bypass (2)

Cesium 多边形增加文字标签(polygon 加 label)多边形中心点偏移问题解决

Wangxinling, tanweiwei Shanhai (extended version of Chorus) online audition lossless FLAC Download

frp实现内网穿透

How to handle computer security certificate errors

Jenkins - 内置变量访问

Ti am3352/54/59 industrial core board hardware specification
随机推荐
《低代码解决方案》——覆盖工单、维修和财务全流程的数字化售后服务低代码解决方案
TI AM3352/54/59 工业核心板硬件说明书
Scoped attribute and lang attribute in style
MySQL interview question set
Cesium 获取屏幕所在经纬度范围
What are the risks of opening a compass stock account? Is it safe to open a compass account
SQL 注入繞過(二)
深入解析kubernetes controller-runtime
Jenkins - Groovy Postbuild 插件丰富 Build History 信息
The interviewer asked: can you simulate the new operator of JS
To understand what is synchronous, asynchronous, serial, parallel, concurrent, process, thread, and coroutine
File transfer protocol --ftp
4G-learn from great partners
Jenkins - Pipeline concept and creation method
yarn下载报错There appears to be trouble with your network connection. Retrying.
Ti am3352/54/59 industrial core board hardware specification
Machine learning (x) reinforcement learning
Dynamic Host Configuration Protocol
SQL 注入绕过(三)
云平台kvm迁移本地虚拟机记录