当前位置:网站首页>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 主从数据库,进行读写分离,一主多从部署,主库只用来写,从库用来读
第四种:
+缓存:热点数据存缓存
边栏推荐
- Chuantu microelectronics ca-if1051 can-fd transceiver
- 双三次差值bicubic
- JDBC-DAO层实现
- WinForm implementation window is always at the top level
- [batch dos-cmd command - summary and summary] - commands related to Internet access and network communication (Ping, Telnet, NSLOOKUP, ARP, tracert, ipconfig)
- Chuantuwei ca-is3720lw alternative material No. iso7820fdw
- Pit encountered by pytorch: why can't l1loss decrease during model training?
- WinForm实现窗口始终在顶层
- 三年营收连续下滑,天地壹号困在醋饮料里
- 单位转换-毫米转像素-像素转毫米
猜你喜欢
Terms and concepts related to authority and authentication system
Application scheme | application of Sichuan earth microelectronics ca-is398x in PLC field
Understand the reasons for impedance matching of PCB circuit board 2021-10-07
Keil and Proteus joint commissioning
Debian introduction
[distillation] pointdistiller: structured knowledge distillationwards efficient and compact 3D detection
机器学习笔记 - 时间序列的线性回归
Modular programming of digital light intensity sensor module gy-30 (main chip bh1750fvi) controlled by single chip microcomputer (under continuous updating)
VectorDraw Developer Framework 10.10
微信小程序开通客服消息功能开发
随机推荐
PI Ziheng embedded: This paper introduces the multi-channel link mode of i.mxrt timer pit and its application in coremark Test Engineering
Introduction to Sichuan Tuwei ca-is3082wx isolated rs-485/rs-422 transceiver
smartBugs安装小问题总结
基于激光雷达的林业调查常用术语及含义锦集
【批处理DOS-CMD命令-汇总和小结】-文件与目录操作命令(md、rd、xcopy、dir、cd、set、move、copy、del、type、sort)
C#获取exe的版本号-文件版本and程序集版本
力扣76题,最小覆盖字串
Runtime——methods成员变量,cache成员变量
Path planner based on time potential function in dynamic environment
基于地面点稀少的LiDAR点云的茂密森林蓄积量估算
Storage of Galileo broadcast ephemeris in rtklib-b33
Chuantu microelectronics high speed and high performance rs-485/422 transceiver series
Chuantu microelectronics ca-if1051 can-fd transceiver
One "stone" and two "birds", PCA can effectively improve the dilemma of missing some ground points under the airborne lidar forest
VectorDraw Developer Framework 10.10
STL tutorial 4- input / output stream and object serialization
[batch dos-cmd command - summary and summary] - file and directory operation commands (MD, RD, xcopy, dir, CD, set, move, copy, del, type, sort)
单位转换-毫米转像素-像素转毫米
Accès à la boîte aux lettres du nom de domaine Lead à l'étranger
[distillation] pointdistiller: structured knowledge distillationwards efficient and compact 3D detection