当前位置:网站首页>MySQL slow query
MySQL slow query
2022-04-23 05:00:00 【Promote wine】
One . Slow query Introduction
MySQL The slow query log of is MySQL A type of logging provided , It is used to record in MySQL The response time in exceeds the specified threshold SQL sentence , Running time exceeds long_query_time It's worth it SQL, Will be recorded in the slow query log .
By default ,MySQL The database does not start the slow query log , Manual opening required . If it's not for tuning , It is generally not recommended to open , Because opening slow query log will bring some performance impact more or less .
stay SQL Server We use SQL Profile To record SQL The implementation of , stay Oracle We can use AWR、ASH Report to analyze history SQL The implementation of , A similar tuning approach maps to MySQL in , This corresponds to the slow query log .
Two . Parameter Introduction
slow_query_log: Open slow query log or not ,1 Open for indication ,0 Means closing .
slow_query_log_file:MySQL Slow query log storage path .
long_query_time : Slow query threshold (s), When the query time is longer than the set threshold , Log .
log_queries_not_using_indexes: Queries that are not indexed are also recorded in the slow query log .
log_throttle_queries_not_using_indexes: Indicates that... Is allowed to be recorded every minute slow_log Not indexed sql Number of statements (0 For unlimited , If it is a fixed value , It may not be recorded sql).
log_output: How to store logs .’FILE’ Means to save to a file ,‘TABLE’ Indicates that it is stored in the system table . because FILE The mode overhead is relatively low , So the default is FILE.
log_slow_admin_statements = 1: Record ALTER TABLE And so on
log_slow_slave_statements = 1: Record slow queries generated from the server
min_examined_row_limit = 100 :SQL The number of scanning lines is greater than or equal to 100 Lines will be recorded
Open slow query log or not
show variables like '%slow_query_log%';
Slow query threshold (s), When the query time is longer than the set threshold , Log
show variables like '%long_query_time%';
3、 ... and . Open slow query log
-- Slow query threshold (s), When the query time is longer than the set threshold , Log .
set global long_query_time = 2;
-- Queries that are not indexed are also recorded in the slow query log
set global log_queries_not_using_indexes = 1;
-- Indicates that... Is allowed to be recorded every minute slow_log Not indexed sql Number of statements (0 For unlimited , If it is a fixed value , It may not be recorded sql).
set global log_throttle_queries_not_using_indexes = 0;
-- QL The number of scanning lines is greater than or equal to 100 Lines will be recorded
set global min_examined_row_limit = 100;
-- Turn on
set global slow_query_log = 1;
版权声明
本文为[Promote wine]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230457444723.html
边栏推荐
- [winui3] write an imitation Explorer file manager
- How can continuous integration (CI) / continuous delivery (CD) revolutionize automated testing
- Leetcode -- heuristic search
- Informatics Olympiad 1955: [11noip popularization group] Swiss round | openjudge 4.1 4363: Swiss round | Luogu p1309 [noip2011 popularization group] Swiss round
- Mac 进入mysql终端命令
- C list field sorting contains numbers and characters
- Special topic of data intensive application system design
- MySQL time function query
- Thoughts on a small program
- What are the redis data types
猜你喜欢
DIY is an excel version of subnet calculator
[database] MySQL multi table query (I)
Thoughts on a small program
Arduino UNO r3+LCD1602+DHT11
Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)
Pixel 5 5g unlocking tutorial (including unlocking BL, installing edxposed and root)
拼了!两所A级大学,六所B级大学,纷纷撤销软件工程硕士点!
泰克示波器DPO3054自校准SPC失败维修
Simply drag objects to the item bar
跨境电商 | Facebook 和 Instagram:哪个社交媒体更适合你?
随机推荐
[winui3] Écrivez une copie du gestionnaire de fichiers Explorer
解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
PHP 统计指定文件夹下文件的数量
Better way to read configuration files than properties
Com alibaba. Common methods of fastjson
Innovation training (10)
Innovation training (XII) reptile
View analysis of scenic spots in ArcGIS
Field injection is not recommended using @ Autowired
Informatics Aosai yibentong 1212: letters | openjudge 2.5 156: Letters
POI export message list (including pictures)
什么是指令周期,机器周期,和时钟周期?
PHP+MySQL 制作留言板
静态流水线和动态流水线的区别认识
Unity C# 网络学习(四)
List< Map> Replication: light copy and deep copy
Deep learning notes - data expansion
Mac 进入mysql终端命令
[2022 ICLR] Pyramid: low complexity pyramid attention for long range spatiotemporal sequence modeling and prediction
负载均衡简介