当前位置:网站首页>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
边栏推荐
- TI AM3352/54/59 工业核心板硬件说明书
- Description du format geojson (détails du format)
- Embedded must learn, detailed explanation of hardware resource interface -- Based on arm am335x development board (Part 1)
- Fundamentals of scala (3): operators and process control
- 外盘期货哪里可以开户?哪个平台出入金比较安全?
- Jenkins - 内置变量访问
- Hi, you have a code review strategy to check!
- Cesium Click to draw polygons (dynamically draw polygons)
- yarn下载报错There appears to be trouble with your network connection. Retrying.
- fiddle如何使用代理
猜你喜欢

SQL 注入绕过(三)

Use code binding DataGridView control to display tables in program interface

ShardingSphere-proxy-5.0.0建立mysql读写分离的连接(六)

Take n multiple table names of a database as the values of a column in another table (the range can be a table in another database)

Based on am335x development board arm cortex-a8 -- acontis EtherCAT master station development case

Cesium 获取屏幕所在经纬度范围

Cesium Click to draw polygons (dynamically draw polygons)

MySQL interview question set

Adding text labels to cesium polygons the problem of polygon center point offset is solved

Differences between cesium polygon extrudedheight and height
随机推荐
Cesium 点击获取经纬度(二维坐标)
面试官问:能否模拟实现JS的new操作符
Machine learning (x) reinforcement learning
[Yocto RM]9 - QA Error and Warning Messages
Machine learning notes - time series as features
Scala 基础 (三):运算符和流程控制
geojson 格式說明(格式詳解)
SQL injection bypass (2)
TD Hero 线上发布会|7月2日邀你来
MySQL十种锁,一篇文章带你全解析
SQL injection Bypass (2)
Numpy----np. meshgrid()
技术人员如何成为技术领域专家
Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known
4G-learn from great partners
Numpy----np.tile()函数解析
简单文件传输协议TFTP
Jenkins - Groovy Postbuild 插件丰富 Build History 信息
STM32F103的11个定时器
Figure out the difference between MIT, BSD and Apache open source protocols