当前位置:网站首页>Mysql database: use the show profile command to analyze performance
Mysql database: use the show profile command to analyze performance
2022-06-29 22:45:00 【Full stack programmer webmaster】
1、show profile The role of :
Be able to find out the recently executed SQL The running state of the statement , This includes what was done during the run , How much time did each take , utilize proflie function , Can analyze one SQL What is the specific implementation cost , In particular, we can analyze its biggest bottleneck . at present profile The function can provide statistics of resource consumption other than memory , for example CPU、I/O、CONTEXT、SWAP etc. . In most cases ,profile We mainly focus on two columns :Status、Duration, The former means profile State in , The latter is the time-consuming of this state . therefore , Our main concern is to focus on which state it takes the longest , In these States , What can be further optimized .
2、show profile grammar :
SHOW PROFILE [type [, type] … ] [FOR QUERY n] [LIMIT row_count [OFFSET offset]] type Parameters : | ALL: Show all overhead information | BLOCK IO: Blocked I / O times | CONTEXT SWITCHES: Context switching related overhead information | CPU: Show CPU Related overhead information | IPC: Overhead information related to receiving and sending messages | MEMORY : Show memory related overhead , Is useless | PAGE FAULTS : Display page error related overhead information | SOURCE : List the function name corresponding to the corresponding operation and its call location in the source code ( Row number ) | SWAPS: Show swap Cost information related to the number of exchanges LIMIT row_count Clause is used to limit the number of output rows .
3、show profile / show profiles Use :
show profile as well as show profiles Statement can display the sql Statement performance (profiling) Information .
(1)profiling Function by MySQL Session variables : profiling control , The default is OFF The closed position , View the current session Open or not profile function :
select @@profiling; show variables like ‘profiling’;
(2) Turn on profiling:
set profiling=ON;
(3) function SQL:
Just run a few SQL, In order to show profiles Log analysis of .
(4) View results :
(4.1)show profiles
show profiles Displays the most recent statements sent to the server , The number of entries depends on the session variable profiling_history_size Definition , The default is 15, The maximum value is 100. Set to 0 Equivalent to closing profiling Analysis function . except SHOW PROFILE and SHOW PROFILES outside , all sql The performance information of the statements will be recorded , Even the wrong statement .
show profiles;
(4.2)show profile
It is used to analyze the last executed sql Statement's detailed resource usage information and working status , The default display states and their duration .
show profile;
You can give show profile To specify a for query id To see the designated id The sentence of , You can also add new columns to the output . Such as , View users and CPU Use . You can use the following command .( For detailed parameters, please refer to section 2 Dot type Parameters )
show profile cpu,block io for query id;
id by show profiles Of a record found Query_ID.
4、 Scope of action :
(1) This command only works in this session , That is, statements outside this session cannot be parsed . After the analysis function is enabled , All statements in this session are parsed ( Even execute the wrong statement ), except SHOW PROFILE and SHOW PROFILES Two sentences themselves .
(2)profiling It's conversational , When the conversation ends , Related to it profiling Information will disappear with it .
(3)profiling Is for the process (process) Not threads (threads), Therefore, other service processes running on the server may affect the analysis results .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/100070.html Link to the original text :https://javaforall.cn
边栏推荐
- 从检查点恢复后读取不到mysql的数据有那位兄台知道原因吗
- Does rapid software delivery really need to be at the cost of security?
- MySQL backup database Linux
- Analyze apache SH script
- Conceptual understanding of deep learning (notes)
- Phpspreadsheet reading and writing Excel files
- Realizing deep learning framework from zero -- RNN from theory to practice [practice]
- Three development trends of enterprise application viewed from the third technological revolution
- Ce CDC Flink peut - il être utilisé pour la synchronisation incrémentale d'Oracle à MySQL?
- VS2013如何让编写的程序在其它电脑上面也能运行
猜你喜欢

One click file sharing software jirafeau

Still stay up late every day and work overtime to make statements? In fact, you don't know how to make reports efficiently

英语没学好到底能不能做coder,别再纠结了先学起来

Free PDF to word software sharing, these software must know!

Arrange the array into the smallest number_ Reverse pairs in an array (merge Statistics)_ Number of occurrences of a number in an ascending array_ Ugly number (Sword finger offer)

Low code, end-to-end, one hour to build IOT sample scenarios, and the sound network released lingfalcon Internet of things cloud platform

IFLYTEK AI learning machine summer new product launch AI + education depth combination to create a new height of products
![[multithreading] how to implement timer by yourself](/img/a9/dd9489c7a0028dd9d3a6dae9a71deb.png)
[multithreading] how to implement timer by yourself

Problem solving metauniverse, multi communication scheme in online games

5-1 system vulnerability scanning
随机推荐
IFLYTEK AI learning machine summer new product launch AI + education depth combination to create a new height of products
从零实现深度学习框架——LSTM从理论到实战【理论】
grpc的开发详解
Daily question brushing record (VIII)
Summer rainbow comes for dinner
Underlying principles of file operations (file descriptors and buffers)
深入解析kubernetes controller-runtime
MySQL backup database Linux
The details of industry are all made by money and time
Efficient implementation of dynamiccast with template function and specialization function
联通入库|需要各地联通公司销售其产品的都需要先入总库
短视频平台搭建,淡入淡出 支持左滑右滑轮播图
还天天熬夜加班做报表?其实你根本不懂如何高效做报表
新手必须知道的 Kubernetes 架构
MySQL 锁常见知识点&面试题总结
中国数据库崛起,阿里云李飞飞:中国云数据库多种主流技术创新已领先国外
Grep工具
Unicom warehousing | all Unicom companies that need to sell their products need to enter the general warehouse first
Deep parsing of kubernetes controller runtime
Go zero micro Service Practice Series (VII. How to optimize such a high demand)