当前位置:网站首页>MySQL enable slow query
MySQL enable slow query
2022-06-29 11:37:00 【PHP white Xiaobai】
One 、 What is slow query ? Why should there be slow queries ?
The so-called slow query , It's a kind of execution select When inquiring , The execution efficiency is very slow SQL sentence .
In the high concurrency scenario, we need to make all the SQL Statement execution is the fastest , Let users have a good sense of experience . And we have no way to know SQL When the statement is issued in high concurrency, the query is slow , At this time, we need to set or enable slow query , And then use SQL Statements to optimize ;
Usually we will use explain To analyze this SQL, Then you can index the appropriate fields , Conduct SQL Optimize ;
Two 、 Several ways to enable slow query
1. adopt MySQL Database open slow query :
set global slow_query_log=on
set global long_query_time=3;
set global log_queries_not_using_indexes=on
slow_query_log: The slow query log logging on( Turn on )/off( close );
long_query_time:SQL Statement execution time exceeds 3 Is considered a slow query statement , Recorded in the slow query log
log_queries_not_using_indexes: Query whether the unused index is enabled to record slow query logs on( Turn on )/off( close );
2. modify MySQL The configuration file
Temporarily open ( Restart failure )
-------------------------------------------------------------------
long_query_time = 10
log-slow-queries = /var/lib/mysql/mysql-slow.log
Permanent open ( Restart does not fail )
--------------------------------------------------------------------
[mysqld]
slow_query_log = ON
slow_query_log_file = /var/lib/mysql/tmp_slow.log //linux
long_query_time = 1
Mysql View slow query log _Chen_leilei The blog of -CSDN Blog _mysql How to view slow query logs
边栏推荐
- 又拍云 Redis 的改进之路
- 【HBZ分享】AQS + CAS +LockSupport 实现ReentrantLock的原理
- XML外部实体注入漏洞(一)
- 巴比特 | 元宇宙每日必读:HTC 宣布推出首款元宇宙手机,售价约2700元人民币,都有哪些新玩法?...
- (JS) handwritten bind function
- 2.8万字的Callable和Future面试知识点总结,看完我直接面进了字节跳动,原谅我有点飘了(下)
- Qt学习08 启航!第一个应用实例
- 斐波那锲数列与冒泡排序法在C语言中的用法
- 云原生开发必备:首个通用无代码开发平台 iVX 编辑器
- QT learning 15 separation of user interface and business logic
猜你喜欢

How to test the performance of container platform, including stability, expansion efficiency and component performance

Cornerstone of efficient remote office: effective communication | community essay solicitation

多线程高并发服务器:3个问题
![[various * * question series] what are OLTP and OLAP?](/img/3f/48b4108d14d40212f678971c1b62bb.png)
[various * * question series] what are OLTP and OLAP?

Qt学习09 计算器界面代码重构

(JS) filter out keys with value greater than 2 in the object
![Leetcode 535 encryption and decryption of tinyurl [map] the leetcode road of heroding](/img/76/709bbbbd8eb01f32683a96c4abddb9.png)
Leetcode 535 encryption and decryption of tinyurl [map] the leetcode road of heroding

巴比特 | 元宇宙每日必读:HTC 宣布推出首款元宇宙手机,售价约2700元人民币,都有哪些新玩法?...

Bs-gx-017 online examination management system based on SSM

Necessary for cloud native development: the first common codeless development platform IVX editor
随机推荐
(JS) handwriting depth comparison
Modbustcp protocol network learning single channel infrared module (medium shell version)
(JS) responsibility chain mode
MySQL 索引失效的几种类型以及解决方式
XML外部实体注入漏洞(一)
【高并发】2.8万字的Callable和Future面试知识点总结,看完我直接面进了字节跳动,原谅我有点飘了(上)
(JS) imitate an instanceof method
Pull and push ideas behind rxjs observable design principles
TTL serial port learning infrared remote control module can be extended to network control
中科方德技术专家直播:如何基于 OpenStack、Ceph 构建私有云平台? | 第 27 期
Bs-gx-017 online examination management system based on SSM
MySQL开启慢查询
misc3~7
Exclusive interview with head of suss NIFT: the future of Web3 is inseparable from the governance of "everyone for me, I for everyone"
Follow Me Study HCIE-Big Data-Data Mining 第一章 数据挖掘介绍 模块一
QT learning 15 separation of user interface and business logic
Qt学习10 初探 Qt 中的消息处理
Creating postgre enterprise database by ArcGIS
(JS) observer mode
重建中国科研自信——2022最新自然指数排行榜(Nature Index 2022 )公布,中国的研究产出增幅最大...