当前位置:网站首页>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
边栏推荐
- 跨境电商 | Facebook 和 Instagram:哪个社交媒体更适合你?
- Innovation training (10)
- Innovation training (II) task division
- 【数据库】MySQL多表查询(一)
- [WinUI3]編寫一個仿Explorer文件管理器
- 深度学习笔记 —— 语义分割和数据集
- Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
- 多线程基本概念(并发与并行、线程与进程)和入门案例
- Deep learning notes - semantic segmentation and data sets
- Wine (COM) - basic concept
猜你喜欢
JS engine loop mechanism: synchronous, asynchronous, event loop
POI export message list (including pictures)
【数据库】表的查看、修改和删除
持续集成(CI)/持续交付(CD)如何彻底改变自动化测试
MySQL 慢查询
#define 定义常量和宏,指针和结构体
Spell it! Two A-level universities and six B-level universities have abolished master's degree programs in software engineering!
Pixel mobile phone brick rescue tutorial
CLion+OpenCV identify ID number - detect ID number
[2021] Spatio-Temporal Graph Contrastive Learning
随机推荐
selenium模式下切换窗口,抓取数据的实现
Basic concepts of multithreading (concurrency and parallelism, threads and processes) and entry cases
vscode ipynb文件没有代码高亮和代码补全解决方法
Repair of self calibration SPC failure of Tektronix oscilloscope dpo3054
ApplicationContext injection bean
POI export message list (including pictures)
[WinUI3]编写一个仿Explorer文件管理器
Use AES encryption - reuse the wisdom of predecessors
The unity camera rotates with the mouse
Use model load_ state_ Attributeerror appears when dict(): 'STR' object has no attribute 'copy‘
The programmer starts the required application with one click of window bat
Custom switch control
跨境电商 | Facebook 和 Instagram:哪个社交媒体更适合你?
redis和mysql区别
How can continuous integration (CI) / continuous delivery (CD) revolutionize automated testing
2022/4/22
redis数据类型有哪些
深度学习笔记 —— 微调
Graduation project
HRegionServer的详解