首页 / 更多教程 / 性能测试之数据库篇-查询(二)
性能测试之数据库篇-查询(二)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了性能测试之数据库篇-查询(二),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2966字,纯文字阅读大概需要5分钟。
内容图文
![性能测试之数据库篇-查询(二)](/upload/InfoBanner/zyjiaocheng/523/8222e299b94b4fe08ddc105809fe8499.jpg)
profile 分析sql开销
1.使用之前先查看当前数据库的版本信息,低版本无法使用.
show version(); 或者 show variables like
‘%version%‘
2.查看profiling
show variables like
‘%profil%‘
;
result:
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| have_profiling | YES | --只读变量,用于控制是否由系统变量开启或禁用profiling
| profiling | OFF | --开启SQL语句剖析功能
| profiling_history_size | 15 | --设置保留profiling的数目,缺省为15,范围为0至100,为0时将禁用p
show profiles; 查看是否开启,效果同上.
3.查看使用说明
help profile;
4.开启profile
set profiling=1; 赋值时候不要有多余的空格.
5.运行sql,查看对应的profile
select * from test ;
show profiles;
result:
+----------+------------+--------------------------------------------------------------------------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+--------------------------------------------------------------------------------------------------------------------------+
| 28 | 0.00033575 | select * from test |
+----------+------------+--------------------------------------------------------------------------------------------------------------------------+
分析sql性能,分析的时候可以加上对应的开销字段
show profile [cpu,io][all]
for
query 28 方括号中的开销项只为示意项,不见得就能执行 利用all 可全部代替
show profile
for
query 28 ;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| starting | 5.7E-5 |
| checking permissions | 7E-6 |
| Opening tables | 1.7E-5 |
| init | 2.3E-5 |
| System lock | 8E-6 |
| optimizing | 5E-6 |
| statistics | 1.1E-5 |
| preparing | 9E-6 |
| executing | 3E-6 |
| Sending data | 8.8E-5 |
|
end
| 5E-6 |
| query
end
| 6E-6 |
| closing tables | 5E-6 |
| freeing items | 7.8E-5 |
| cleaning up | 1.5E-5 |
+----------------------+----------+
6.关闭
set profiling=off;
文章参考https://www.php.cn/mysql-tutorials-416130.html
show profile ALL for query 10;
性能测试之数据库篇-查询(二)
标签:空格 tutorial perm http items on() osi his variable
本文系统来源:https://www.cnblogs.com/zhaohongxiang/p/12829439.html
内容总结
以上是互联网集市为您收集整理的性能测试之数据库篇-查询(二)全部内容,希望文章能够帮你解决性能测试之数据库篇-查询(二)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。