当前位置:网站首页>不是吧?还有人不会定位线上MySQL慢查询问题?
不是吧?还有人不会定位线上MySQL慢查询问题?
2022-08-05 11:44:00 【InfoQ】
1. 慢查询日志的作用
2. 慢查询日志的配置
2.1 查看是否开启了慢查询日志
show variables like 'slow_query_log';

2.2 开启慢查询日志
set global slow_query_log=1;

2.3 设置慢查询日志的阈值

set long_query_time=1;

2.4 修改慢查询日志位置
show variables like '%slow_query_log_file%';

2.5 记录更多慢查询SQL

set global log_slow_admin_statements=ON;


set global log_queries_not_using_indexes=ON;

3. 慢查询日志的使用
select * from user;
cat /usr/local/mysql/data/localhost_slow.log

4. 分析慢查询日志
常用参数有
-s: 表示按何种方式排序:
c: 访问次数
l: 锁定时间
r: 返回记录
t: 查询时间
al: 平均锁定时间
ar: 平均返回记录数
at: 平均查询时间
-t: 返回前面多少条的数据;
4.1 查询返回结果最多的10条SQL:

4.2 查询耗时最长的10条SQL:

边栏推荐
- 5G NR system messages
- No developers, received a job to develop an IoT system, do you want to do it?
- 解决2022Visual Studio中scanf返回值被忽略问题
- 【HMS core】【FAQ】Health Kit、Ads kit、push Kit典型问题合集5
- 苹果Meta都在冲的Pancake技术,中国VR团队YVR竟抢先交出产品答卷
- 机器学习——逻辑回归
- Introduction to the Evolution of Data Governance System
- TiDB 6.0 Placement Rules In SQL Usage Practice
- 动手学深度学习_GoogLeNet / Inceptionv1v2v3v4
- Http-Sumggling Cache Vulnerability Analysis
猜你喜欢

【硬件架构的艺术】学习笔记(3)处理多个时钟

机器学习——集成学习

祝所有码农七夕快乐~

苹果Meta都在冲的Pancake技术,中国VR团队YVR竟抢先交出产品答卷

解决2022Visual Studio中scanf返回值被忽略问题

Http-Sumggling Cache Vulnerability Analysis

Official release 2022 Nanjing Zhibo Expo is scheduled to be held in Xinzhuang National Exhibition in October

Hands-on Deep Learning_GoogLeNet / Inceptionv1v2v3v4

四、kubeadm单master

163_技巧_Power BI 一键批量建立自定义字段参数
随机推荐
Android development with Kotlin programming language II Conditional control
版本控制篇 | 龙智邀您共赴GOPS全球运维大会,探索大规模、敏捷、高质量、开放式的软件研发与运营之路
No developers, received a job to develop an IoT system, do you want to do it?
WingIDE 7.2.0 远程调试
Image segmentation model - a combination of segmentation_models_pytorch and albumations to achieve multi-category segmentation
金融业“限薪令”出台/ 软银出售过半阿里持仓/ DeepMind新实验室成立... 今日更多新鲜事在此...
Google启动通用图像嵌入挑战赛
我要抓狂了。。又回到了几天不能A一道题的时候
莅临GOPS大会龙智展位,获取Forrester最新报告:《Forrester Wave:2021年第四季度企业服务管理报告》
How about Ping An Mengwa Card Insurance?Let parents read a few ways to identify products
Version Control | Longzhi invites you to go to the GOPS Global Operation and Maintenance Conference to explore the road of large-scale, agile, high-quality and open software development and operation
EOS的共识机制与区块生成
hdu1455 Sticks (search+pruning+pruning+.....+pruning)
解决运行文件消失、C盘空间不断缩小而且找不到文件位置的问题
2022 CCF国际AIOps挑战赛决赛暨AIOps研讨会报名已开启
Hands-on Deep Learning_GoogLeNet / Inceptionv1v2v3v4
问题征集丨ECCV 2022中国预讲会 · Panel专题研讨会
Http-Sumggling Cache Vulnerability Analysis
Gray value and thermal imaging understanding
祝所有码农七夕快乐~