当前位置:网站首页>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
边栏推荐
- 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)
- Underlying principles of file operations (file descriptors and buffers)
- 为什么在局域网(ERP服务器)共享文件夹上拷贝文件时导致全局域英特网断网
- 合宙AIR32F103CBT6开发板上手报告
- Daily question brushing record (VIII)
- Advanced use of the optional class
- Evolution from stand-alone to distributed database storage system
- 论文浅尝 | KR-GCN: 知识感知推理的可解释推荐系统
- Free PDF to word software sharing, these software must know!
- Mysql database: read write separation
猜你喜欢
Why does copying files on a shared folder on a local area network (ERP server) result in the loss of the local Internet

还天天熬夜加班做报表?其实你根本不懂如何高效做报表

把数组排成最小的数_数组中的逆序对(归并统计法)_数字在升序数组中出现的次数_丑数(剑指offer)

Unicom warehousing | all Unicom companies that need to sell their products need to enter the general warehouse first

论文浅尝 | KR-GCN: 知识感知推理的可解释推荐系统
![Realizing deep learning framework from zero -- LSTM from theory to practice [theory]](/img/ac/164140eff1a6518d49ce25599d9c7b.png)
Realizing deep learning framework from zero -- LSTM from theory to practice [theory]
MySQL lock common knowledge points & summary of interview questions

Go zero micro Service Practice Series (VII. How to optimize such a high demand)

Kubernetes architecture that novices must know

#第三天
随机推荐
Vs2013 how to make the program run on other computers
Huawei's software testing director with 7 years' experience, several suggestions for all students who want to switch to software testing
Golang code specification sorting
Analyze apache SH script
Ansible自动化运维
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)
Three development trends of enterprise application viewed from the third technological revolution
Mysql database: read write separation
中国数据库崛起,阿里云李飞飞:中国云数据库多种主流技术创新已领先国外
The client can connect to remote MySQL
Processing of error b6267342 reported by AIX small machine in production environment
math_基本初等函数图型(幂函数/指数/对数/三角/反三角)
leetcode 416. Partition Equal Subset Sum 分割等和子集(中等)
阶段性总结与思考
Grep工具
Problem solving metauniverse, multi communication scheme in online games
MySQL lock common knowledge points & summary of interview questions
wirehark数据分析与取证infiltration.pacapng
Polymorphism of laravel association model
Day9 ---- 用户注册与登录