Heim  >  Artikel  >  Datenbank  >  MySQL profiling性能分析工具

MySQL profiling性能分析工具

WBOY
WBOYOriginal
2016-06-07 16:07:33978Durchsuche

MySQL 的 Query Profiler 是一个使用非常方便的 Query 诊断分析工具,通过该工具可以获取一条Query 在整个执行过程中 多种资源的

简述:

MySQL 的 Query Profiler 是一个使用非常方便的 Query 诊断分析工具,通过该工具可以获取一条Query 在整个执行过程中 多种资源的消耗情况,如 CPU,IO,IPC,SWAP 等,以及发生的 PAGE FAULTS,CONTEXT SWITCHE 等等,同时还能得到该 Query 执行过程中 MySQL 所调用的各个函数在源文件中的位置。

通过慢日志查询可以知道哪些SQL语句执行效率低下,通过explain我们可以得知SQL语句的具体执行情况,,索引使用等,还可以结合show命令查看执行状态。如果觉得explain的信息不够详细,可以同通过profiling命令得到更准确的SQL执行消耗系统资源的信息。

profiling默认是关闭的

1. show variables like '%profiling%';(查看profiling信息)

MySQL profiling性能分析工具

2. set profiling=1;(开启profiling)

MySQL profiling性能分析工具

3. 执行SQL查询

 例:select goods_name from ecs_goods where goods_id

 show  profiles;

MySQL profiling性能分析工具

4. show profile for query 4;

show profile 的格式如下:

MySQL profiling性能分析工具

# The ideal of life is for ideal life! #

本文永久更新链接地址

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn