4.mysql profile的使用方法
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了4.mysql profile的使用方法,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3843字,纯文字阅读大概需要6分钟。
内容图文
![4.mysql profile的使用方法](/upload/InfoBanner/zyjiaocheng/446/1b17b58498c94bdc8e367d932ac36238.jpg)
profile的使用
1、作用
使用profile可以对某一条sql性能进行分析
2、语法
mysql> show variables like ‘%profil%‘;
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| have_profiling | YES |
| profiling | ON | 开启profile功能
| profiling_history_size | 15 | profile能记录多少条sql
+------------------------+-------+
set profiling = 0/1; 关闭或开启profile功能
mysql> show profiles; 查看当前profile记录的所有sql
+----------+-------------+------------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+-------------+------------------------------------------------------------+
| 1 | 0.00163850 | show variables like ‘%profil%‘ |
| 2 | 0.00005825 | show warnings |
| 3 | 23.85836475 | select * from course c left join study s on c.age = s.snum |
| 4 | 0.23801475 | select * from study s left join course c on c.age = s.snum |
| 5 | 0.00010450 | set profiling=1 |
| 6 | 0.00190400 | show variables like ‘%prifil%‘ |
| 7 | 0.00175100 | show variables like ‘%profil%‘ |
+----------+-------------+------------------------------------------------------------+
mysql> show profile for query 4; 查看某个Query的执行持续时间分布
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| starting | 0.000131 |
| checking permissions | 0.000008 |
| checking permissions | 0.000005 |
| Opening tables | 0.000015 |
| init | 0.000023 |
| System lock | 0.000009 |
| optimizing | 0.000008 |
| statistics | 0.000027 |
| preparing | 0.000012 |
| executing | 0.000004 |
| Sending data | 0.237726 |
| end | 0.000010 |
| query end | 0.000007 |
| closing tables | 0.000008 |
| freeing items | 0.000014 |
| cleaning up | 0.000010 |
+----------------------+----------+
show profile [all|cpu|block io|……] for query number; 可以查看[全部|cpu相关|io相关]细节
3、含义分析
show profile all for query n;
横向栏意义
+----------------------+----------+----------+------------+
"Status": "query end", 状态
"Duration": "1.751142", 持续时间
"CPU_user": "0.008999", cpu用户
"CPU_system": "0.003999", cpu系统
"Context_voluntary": "98", 上下文主动切换
"Context_involuntary": "0", 上下文被动切换
"Block_ops_in": "8", 阻塞的输入操作
"Block_ops_out": "32", 阻塞的输出操作
"Messages_sent": "0", 消息发出
"Messages_received": "0", 消息接受
"Page_faults_major": "0", 主分页错误
"Page_faults_minor": "0", 次分页错误
"Swaps": "0", 交换次数
"Source_function": "mysql_execute_command", 源功能
"Source_file": "sql_parse.cc", 源文件
"Source_line": "4465" 源代码行
+----------------------+----------+----------+------------+
纵向栏意义
+----------------------+----------+----------+------------+
starting:开始
checking permissions:检查权限
Opening tables:打开表
init : 初始化
System lock :系统锁
optimizing : 优化
statistics : 统计
preparing :准备
executing :执行
Sending data :发送数据
Sorting result :排序
end :结束
query end :查询 结束
closing tables : 关闭表 /去除TMP 表
freeing items : 释放物品
cleaning up :清理
+----------------------+----------+----------+------------+
4.mysql profile的使用方法
标签:ring duration clean 执行 准备 swap lock func statistic
本文系统来源:https://www.cnblogs.com/unsigned1995/p/14154031.html
内容总结
以上是互联网集市为您收集整理的4.mysql profile的使用方法全部内容,希望文章能够帮你解决4.mysql profile的使用方法所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。