mysql性能分析工具profile使用教程

上传人:bin****86 文档编号:59370780 上传时间:2018-11-06 格式:DOCX 页数:16 大小:19.31KB
返回 下载 相关 举报
mysql性能分析工具profile使用教程_第1页
第1页 / 共16页
mysql性能分析工具profile使用教程_第2页
第2页 / 共16页
mysql性能分析工具profile使用教程_第3页
第3页 / 共16页
mysql性能分析工具profile使用教程_第4页
第4页 / 共16页
mysql性能分析工具profile使用教程_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《mysql性能分析工具profile使用教程》由会员分享,可在线阅读,更多相关《mysql性能分析工具profile使用教程(16页珍藏版)》请在金锄头文库上搜索。

1、我真正系统地接触和学习党的基本知识是在这次中级党校的培训班上。通过学习,了解了党的发展历程,对党的性质、宗旨、任务等基本知识有了进一步的了解mysql性能分析工具profile使用教程分析sql执行带来的开销是优化sql的重要手段。在mysql数据库中,可以通过配置profiling参数来启用sql剖析。该参数可以在全局和session级别来设置。对于全局级别则作用于整个mysql实例,而session级别紧影响当前session。该参数开启后,后续执行的sql语句都将记录其资源开销,诸如io,上下文切换,cpu,memory等等。根据这些开销进一步分析当前sql瓶颈从而进行优化与调整。本文描

2、述了如何使用mysql profile,不涉及具体的样例分析。1、有关profile的描述代码如下:-当前版本 show variables like version;+-+-+| variable_name | value |+-+-+| version | 5.6.17-enterprise-commercial-advanced |+-+-+-查看profiling系统变量 show variables like %profil%;+-+-+| variable_name | value |+-+-+| have_profiling | yes | -只读变量,用于控制是否由系统变量开启

3、或禁用profiling| profiling | off | -开启sql语句剖析功能| profiling_history_size | 15 | -设置保留profiling的数目,缺省为15,范围为0至100,为0时将禁用profiling+-+-+profiling 539if set to 0 or off (the default), statement profiling is disabled. if set to 1 or on, statement profis enabled and the show profile and show profiles statemen

4、ts provide access to profinformation. see section 13.7.5.32, “show profiles syntax”.this variable is deprecated in mysql 5.6.8 and will be removed in a future mysql release.profiling_history_size 539the number of statements for which to maintain profiling information if profiling 539 isenabled. the

5、default value is 15. the maximum value is 100. setting the value to 0 effectivelydisables profiling. see section 13.7.5.32, “show profiles syntax”.this variable is deprecated in mysql 5.6.8 and will be removed in a future mysql release.-获取profile的帮助 help profile;name: show profiledescription:syntax:

6、show profile type , type . for query nlimit row_count offset offsettype:all -显示所有的开销信息| block io -显示块io相关开销| context switches -上下文切换相关开销| cpu -显示cpu相关开销信息| ipc -显示发送和接收相关开销信息| memory -显示内存相关开销信息| page faults -显示页面错误相关开销信息| source -显示和source_function,source_file,source_line相关的开销信息| swaps -显示交换次数相关开销的

7、信息the show profile and show profiles statements display profilinginformation that indicates resource usage for statements executedduring the course of the current session.*note*: these statements are deprecated as of mysql 5.6.7 and will beremoved in a future mysql release. use the performance schem

8、a instead;see.-上面描述从5.6.7开始该命令将会被移除,用performance schema instead代替-在oracle数据库中,是通过autotrace来剖析单条sql并获取真实的执行计划以及其开销信息2、开启porfiling代码如下:-启用session级别的profiling set profiling=1;query ok, 0 rows affected, 1 warning (0.00 sec)-验证修改后的结果 show variables like %profil%;+-+-+| variable_name | value |+-+-+| have_

9、profiling | yes | profiling | on | profiling_history_size | 15 |+-+-+-发布sql查询 select count(*) from customer;+-+| count(*) |+-+| 599 |+-+-查看当前session所有已产生的profile show profiles;+-+-+-+| query_id | duration | query |+-+-+-+| 1 | 0. | show variables like %profil% | 2 | 0. | select count(*) from custome

10、r |+-+-+-+2 rows in set, 1 warning (0.01 sec)-我们看到有2个warning,之前一个,现在一个 show warnings; -下面的结果表明show profiles将来会被performance schema替换掉+-+-+-+| level | code | message |+-+-+-+| warning | 1287 | show profiles is deprecated and will be removed in a future release. please use performance schema instead |+

11、-+-+-+3、获取sql语句的开销信息代码如下:-可以直接使用show profile来查看上一条sql语句的开销信息-注,show profile之类的语句不会被profiling,即自身不会产生profiling-我们下面的这个show profile查看的是show warnings产生的相应开销 show profile;+-+-+| status | duration |+-+-+| starting | 0. | query end | 0. | closing tables | 0. | freeing items | 0. | cleaning up | 0. |+-+-+-如下面的查询show warnings被添加到profiles show profiles;+-+-+-+| query_id | duration | query |+-+-+-+| 1 | 0. | show varia

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 总结/报告

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号