当前位置:网站首页>MySQL slow query record
MySQL slow query record
2022-06-23 07:49:00 【hzp666】
Slow query log :MySQL The slow query log records that all executions exceed long_query_time The time of the SQL sentence , Help you find the slow execution SQL, For our convenience SQL To optimize . Slow query log configuration :
By default ,mysql Slow query log is not enabled .
[[email protected] ~]# mysql -u root -p
mysql> show variables like '%slow%';
+------------------------------------+------------------------------+
| Variable_name | Value |
+------------------------------------+------------------------------+
| log_slow_admin_statements | OFF |
| log_slow_filter | |
| log_slow_rate_limit | 1 |
| log_slow_rate_type | session |
| log_slow_slave_statements | OFF |
| log_slow_sp_statements | ON |
| log_slow_verbosity | |
| max_slowlog_files | 0 |
| max_slowlog_size | 0 |
| slow_launch_time | 2 |
| slow_query_log | OFF |
| slow_query_log_always_write_time | 10.000000 |
| slow_query_log_file | /var/lib/mysql/rh64-slow.log |
| slow_query_log_timestamp_always | OFF |
| slow_query_log_timestamp_precision | second |
| slow_query_log_use_global_control | |
+------------------------------------+------------------------------+
16 rows in set (0.01 sec)1、 You can configure the my.cnf file , Automatic configuration at service startup
[[email protected] ~]# cat /etc/my.cnf
restart server after , see :
mysql> show variables like '%slow%';
2、 Configure... In the system slow-query-log
mysql> set @@global.slow_query_log = on;
mysql> show variables like '%slow%';
3、 View slow query log information
[[email protected] mysql]# tail rh64-slow.log
Record statements that do not use indexes :
mysql> set @@global.log_queries_not_using_indexes=on;
Query OK, 0 rows affected (0.00 sec)
test :
mysql> select count(*) from emp1 where empno=7788;
+----------+
| count(*) |
+----------+
| 688128 |
+----------+
1 row in set (4.03 sec)[[email protected] mysql]# tail rh64-slow.log
4、 adopt mysqldumpslow Tools to view slow query logs
[[email protected] mysql]# mysqldumpslow
[[email protected] mysql]# mysqldumpslow --help
[[email protected] mysql]# mysqldumpslow rh64-slow.log
Sort by average lock time , Before searching 10 name :
[[email protected] mysql]# mysqldumpslow -s al -n 10 rh64-slow.log
Reading mysql slow query log from rh64-slow.log
Count: 3 Time=0.00s (0s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost
# Schema: prod Last_errno: N Killed: N
# Query_time: N.N Lock_time: N.N Rows_sent: N Rows_examined: N Rows_affected: N
# Bytes_sent: N
SET timestamp=N;
insert into emp1 select * from emp1
Count: 1 Time=0.00s (0s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost
# Schema: prod Last_errno: N Killed: N
# Query_time: N.N Lock_time: N.N Rows_sent: N Rows_examined: N Rows_affected: N
# Bytes_sent: N
use prod;
SET timestamp=N;
insert into emp1 select * from emp1
Count: 1 Time=0.00s (0s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost
# Schema: prod Last_errno: N Killed: N
# Query_time: N.N Lock_time: N.N Rows_sent: N Rows_examined: N Rows_affected: N
# Bytes_sent: N
SET timestamp=N;
select count(*) from emp1 where empno=N
————————————————
Link to the original text :https://blog.csdn.net/weixin_42347763/article/details/113276922
边栏推荐
- 跳跃表原理
- MySQL on duplicate key and PgSQL on conflict (primary key) handle primary key conflicts
- Minio single node deployment Minio distributed deployment fool deployment process (I)
- To conquer salt fields and vegetable fields with AI, scientific and technological innovation should also step on the "field"
- 干货来了|《PaaS》合辑抢先看~
- Online text filter less than specified length tool
- Unity to wechat applet games
- Can you think of a better way to solve the problem of string inversion?
- 【唠嗑篇】普通人到底该怎么学技术啊?
- QT project error: -1: error: cannot run compiler 'clang++' Output:mingw32-make. exe
猜你喜欢

Qt 使用QDomDocument读取xml文件

Talk about routing design in service governance

Solutions to abnormal network connection of Xiaoai speakers

Simpledateformat thread safety issues

Hcip Road

Vs problems when connecting to SQL myconn OPen(); cannot execute

The sandbox has reached a cooperation with football player to bring popular football cartoons and animation into the metauniverse

HCIP之路第八次实验

Qt工程报错:-1: error: Cannot run compiler ‘clang++‘. Output:mingw32-make.exe

How to tag and label naming before the project release
随机推荐
Start appium
Wechat multiplayer chat and Roulette Games (websocket Implementation)
Download the OSS file and modify the file name
Pseudocode specification, pseudocode online editor,
Guava cache usage summary
Yolov5 detecting small targets (with source code)
MIT CMS. 300 session 12 – identity construction Part 2
传智教育 | 多人协作开发出现代码冲突,如何合并代码?
Vs problems when connecting to SQL myconn OPen(); cannot execute
Both are hard disk partitions. What is the difference between C disk and D disk?
Unity picture loading and saving
数学知识:快速幂—快速幂
[cloud computing event] vocational skill competition -- container development example pig rapid development framework
【星球精选】如何高效构建 Roam 与 theBrain 间细粒度双向链接?
Acwing第 56 场周赛【完结】
左乘右乘矩阵问题
What is customer experience automation?
【云计算赛项】职业技能竞赛--容器开发部分例题Pig快速开发框架
mysql中多表视图性能疑惑
Simpledateformat thread safety issues