当前位置:网站首页>Mysql面试-执行sql响应比较慢,排查思路。
Mysql面试-执行sql响应比较慢,排查思路。
2022-06-25 06:41:00 【jack_bob】
1.没有索引或者sql没有命中索引导致索引失效
2.单表数据量过多,导致查询瓶颈
3.网络原因或者机器负载过高
4.热点数据导致单点数据负载不均衡
第一种:
检查慢查询日志,找出耗时最长的sql语句,进行分析,
如:利用执行计划explain,去查询是否命中了索引,没有命中的话,尝试优化sql语句,保证sql去索引执行。
添加索引:符合最左匹配原则
最左匹配原则:最左优先,以最左边的为起点任何连续的索引都能匹配上。同时遇到范围查询(>、<、between、like)就会停止匹配。
第二种:
对表进行拆分:1.水平分表 2.垂直分表
参考:垂直分表和水平分表
如果单表拆分1000张表
分库:根据后缀0-100 放一个库 依次类推,分10个库,根据业务主键,把请求路由切到不同的库进行查询,均摊流量
第三种:
读写分离:myqsql 主从数据库,进行读写分离,一主多从部署,主库只用来写,从库用来读
第四种:
+缓存:热点数据存缓存
边栏推荐
- Sichuan earth microelectronics ca-is1200 isolated operational amplifier for current detection
- WinForm implementation window is always at the top level
- 【QT】Qt 5 的程序:打印文档
- CGLIB动态代理
- [batch dos-cmd command - summary and summary] - CMD extended command and function (CMD /e:on, CMD /e:off)
- 力扣76题,最小覆盖字串
- (tool class) quickly add time to code in source insight
- 指南针可以开股票账户吗?安全吗?
- SQL solve select basic statement
- 栅格地图(occupancy grid map)构建
猜你喜欢

三年营收连续下滑,天地壹号困在醋饮料里

Function template_ Class template

Terms and concepts related to authority and authentication system

CPDA|数据分析师成长之路如何起步?

PI Ziheng embedded: This paper introduces the multi-channel link mode of i.mxrt timer pit and its application in coremark Test Engineering

npm install 报错 : gyp ERR! configure error

【QT】Qt 5 的程序:打印文档

Ca-is1200u current detection isolation amplifier has been delivered in batch

Home environment monitoring system design (PC version) (mobile app version to be determined)
![[batch dos-cmd command - summary and summary] - add comment command (REM or::)](/img/e9/151885ecd490b0aa83cce0f3a49124.png)
[batch dos-cmd command - summary and summary] - add comment command (REM or::)
随机推荐
海思3559 sample解析:vio
Ns32f103c8t6 can perfectly replace stm32f103c8t6
El input to add words to the tail
php入门基础记录
ELK + filebeat日志解析、日志入库优化 、logstash过滤器配置属性
Chuantu microelectronics high speed and high performance rs-485/422 transceiver series
Keil and Proteus joint commissioning
数据可视化没有重点怎么办?
Four software 2021-10-14 suitable for beginners to draw PCB
Summary of small problems in smartbugs installation
Without "rice", you can cook "rice". Strategy for retrieving missing ground points under airborne lidar forest using "point cloud intelligent mapping"
"Spatial transformation" significantly improves the quality of ground point extraction of cliff point cloud
Understand the reasons for impedance matching of PCB circuit board 2021-10-07
[batch dos-cmd command - summary and summary] - file and directory operation commands (MD, RD, xcopy, dir, CD, set, move, copy, del, type, sort)
Three years of continuous decline in revenue, Tiandi No. 1 is trapped in vinegar drinks
Tuwei Digital Isolator and interface chip can perfectly replace imported brands Ti and ADI
Tupu software digital twin 3D wind farm, offshore wind power of smart wind power
Pytorch遇到的坑:为什么模型训练时,L1loss损失无法下降?
[distillation] pointdistiller: structured knowledge distillationwards efficient and compact 3D detection
【批處理DOS-CMD命令-匯總和小結】-cmd擴展命令、擴展功能(cmd /e:on、cmd /e:off)