当前位置:网站首页>不是吧?还有人不会定位线上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:

边栏推荐
- 163_Tricks_Power BI one-click batch creation of custom field parameters
- Integration testing of software testing
- Naive bayes
- Exploration and practice of transaction link under multi-service mode
- power failure...Trouble trouble trouble!!!
- Custom filters and interceptors implement ThreadLocal thread closure
- 60行从零开始自己动手写FutureTask是什么体验?
- nyoj757 期末考试 (优先队列)
- 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
- 金融业“限薪令”出台/ 软银出售过半阿里持仓/ DeepMind新实验室成立... 今日更多新鲜事在此...
猜你喜欢

2022 CCF International AIOps Challenge Finals and AIOps Seminar Registration Open

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

Qt::qcustomplot 和 qchart数据填充相关

Flink Yarn Per Job - 启动TM,向RM注册,RM分配solt

Android development with Kotlin programming language II Conditional control

灰度值与热成像理解

【硬件架构的艺术】学习笔记(2)同步和复位

365天挑战LeetCode1000题——Day 050 在二叉树中增加一行 二叉树

5G NR system messages

支持向量机SVM
随机推荐
硅谷来信:快速行动,Facebook、Quora等成功的“神器”!
#yyds干货盘点#JS数组和树相互转化
Three methods for extracting facial features
A woman is the most beautiful life in the world
nyoj757 期末考试 (优先队列)
Qt::qcustomplot 和 qchart数据填充相关
163_技巧_Power BI 一键批量建立自定义字段参数
“蘑菇书”是怎样磨出来的?
ECCV 2022 | 视听分割:全新任务,助力视听场景像素级精细化理解
如何用Golang来手写一个Blog - Milu.blog 开发总结
Flink Yarn Per Job - JobManger 申请 Slot
UDP通信
字节秋招二面把我干懵了,问我SYN报文什么情况下会被丢弃?
TiDB 6.0 Placement Rules In SQL 使用实践
Integration testing of software testing
小红的aba子序列(离散化、二分、dp维护区间最短)
普通二本毕业八年,京东就职两年、百度三年,分享大厂心得
shell编程流程控制练习
学生信息管理系统(第一次.....)
hdu2097 nyoj414 sky数 (进制转换)