当前位置:网站首页>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 主从数据库,进行读写分离,一主多从部署,主库只用来写,从库用来读
第四种:
+缓存:热点数据存缓存
边栏推荐
- SQL solve select basic statement
- 【深度学习 轻量型backbone】2022 EdgeViTs CVPR
- Kinsing双平台挖矿家族病毒分析
- [batch dos-cmd command - summary and summary] - application startup and call, service and process operation commands (start, call, and)
- lebel只想前面有星号,但是不想校验
- Without "rice", you can cook "rice". Strategy for retrieving missing ground points under airborne lidar forest using "point cloud intelligent mapping"
- (tool class) use SecureCRT as the communication medium
- C#获取exe的版本号-文件版本and程序集版本
- 如何用svn新建属于自己的分支
- Keil and Proteus joint commissioning
猜你喜欢

【深度学习 轻量型backbone】2022 EdgeViTs CVPR

Sichuan Tuwei ca-if1051 can transceiver has passed aec-q100 grade 1 certification

VectorDraw Developer Framework 10.10

STL教程4-输入输出流和对象序列化

Intel announced five new technological developments, including quantum computing, neural pseudo computing, machine programming, integrated optoelectronics, and secure computing

基于地面点稀少的LiDAR点云的茂密森林蓄积量估算

Research on 3D model retrieval method based on two channel attention residual network - Zhou Jie - paper notes
![[single chip microcomputer project training] multipoint temperature wireless acquisition system based on nRF905](/img/a7/fc5d2f4640322a5d7222cce83c8898.jpg)
[single chip microcomputer project training] multipoint temperature wireless acquisition system based on nRF905

Debian introduction

Construction of occupancy grid map
随机推荐
IAR compiler flashback
Access to foreign lead domain name mailbox
[batch dos-cmd command - summary and summary] - CMD window setting and operation commands (CD, title, mode, color, pause, CHCP, exit)
海思3559 sample解析:vio
AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
基于地面点稀少的LiDAR点云的茂密森林蓄积量估算
npm install 报错 : gyp ERR! configure error
[batch dos-cmd command - summary and summary] - commands related to Internet access and network communication (Ping, Telnet, NSLOOKUP, ARP, tracert, ipconfig)
realsense d455 semantic_slam实现语义八叉树建图
Tuwei Digital Isolator and interface chip can perfectly replace imported brands Ti and ADI
Ns32f103c8t6 can perfectly replace stm32f103c8t6
realsense d455 semantic_ Slam implements semantic octree mapping
神经网络与深度学习-3- 机器学习简单示例-PyTorch
VOCALOID笔记
Redis learning notes
【深度学习 轻量型backbone】2022 EdgeViTs CVPR
Sichuan Tuwei ca-if1051 can transceiver has passed aec-q100 grade 1 certification
STL tutorial 4- input / output stream and object serialization
如何用svn新建属于自己的分支
How to use printf of 51 single chip microcomputer