当前位置:网站首页>MySQL show profile diagnostic SQL and configuration optimization
MySQL show profile diagnostic SQL and configuration optimization
2022-07-22 13:39:00 【, small h】
Show profile brief introduction
Show Profile yes MySQL Provided can be used to analyze the current session ,SQL Statement resource consumption Tools for situation , Can be used for SQL The measurement of tuning . In the current session . By default, it is show profile It's off , Open and save the latest 15 The result of the run For slow SQL, adopt profile Tools for detailed analysis . You can get SQL In the process of execution All resource costs . Such as IO expenses ,CPU expenses , Memory overhead, etc
Usually at work , We will pass some Mysql Provide some syntax to use Show profile ;
# Check whether the database supports show Profile, If you inquire profiling The result is off, You can start it by yourself with the following statement .
show variables like '%profiling%';
################### Turn on profile################
set profiling = on;
################## close profile################
set profiling = off;
######### see show profiles Execute record after opening
show PROFILES;
# Return the following properties
# Query_ID After opening profiling Number of records queried
# Duration On behalf of this query SQL The duration
# The diagnosis SQL( Will show a sql The specific lifecycle of the query )
show profile cpu ,block io for query 1;
# Return the following properties
# ALL : Show all expenses
# BLOCK IO Display block IO expenses
# CONTEXT SWITCHES : The overhead of context switching
# CPU : Show CPU Related expenses
# IPC: Show the cost of sending and receiving
# MEMORY: Show memory related overhead
# PAGE FAULTS The cost of displaying page errors
# SOURCE: Show source_function ,source_file Aspect cost
# SWAPS: Show the cost of switching times
# converting HEAP to MyISM : Query result is too large , There is not enough memory to write to the disk
# creating temp table : Create a temporary table , Copy data into temporary tables , Delete after use ( It's time consuming ).
# copying to temp table on disk : Copy the temporary table in memory to disk ( It's very dangerous , Must be optimized )
# locked : Deadlock
# In addition to using show profile You can also query through the global log ( Never use it in the production environment !!!!!!, It can only be used in the test environment )( Not recommended , Suggested pass show profile)
# Check the global log on status show variables like '%general_log%'
边栏推荐
- Leetcode - zj - future04: distribution des marchandises en magasin
- Idea decompiles the entire jar package source code
- ApacheCon Asia 2022 开启报名:Pulsar 技术议题重磅亮相
- leetcode-735:行星碰撞
- IDEA反編譯出整個jar包源碼
- Solution to the problem that the ideal log displays a question mark and cannot be opened by double clicking
- LeetCode_动态规划_困难_44.通配符匹配
- Leetcode-814: binary tree pruning
- Auto.js学习笔记18:子线程和定时器配合使用(结尾有示例)
- [mysql] basic database operations
猜你喜欢
How to install MySQL
稀土开发者大会|StreamNative 翟佳、刘德志分享云原生技术变革之路
直播回顾| Apache Pulsar Meetup 精彩回放(含 PPT 下载)
[mysql] basic database operations
How to use call, bind and apply correctly
[ManageEngine] seven ways to strengthen the security of enterprise privileged access
Small knowledge points with notes
ApacheCon Asia 2022 开启报名:Pulsar 技术议题重磅亮相
TiDB 高并发写入场景最佳实践
One bite of Stream(9)
随机推荐
leetcode-307:区域和检索 - 数组可修改
如果想和开发少battle,那你一定要懂数据库
MVN multi module selection specified module deploy
Leetcode-307: region and retrieval - array modifiable
PCBA design of body fat scale
Leetcode-745: prefix and suffix search
How to do member marketing? 3 tips to retain customers!
2022/07/21 --- maximum value of sliding window;
麒麟系统 QT代码 出现 使用未声明的标识符“MainWindow“
Leetcode-676: implement a magic dictionary
【PostgreSQL 15】PostgreSQL 15对UNIQUE和NULL的改进
Robin Lee: driverless driving is the greatest innovation of human value creation
Fast-lio2: fast and direct lidar and inertial navigation odometer
2022/07/20--- convert string to integer; Maximum value of sliding window
Live review | wonderful playback of Apache pulsar meetup (including PPT download)
Small knowledge points with notes
【微信小程序】Image图片加载(78/100)
Solve the problem of using external files in Google Labs
[advanced C language] learning about flexible arrays
Deep and shallow copy