首页 > MySQL > MySQL 性能跟踪语句

MySQL 性能跟踪语句

来源:原创 作者:thomas 分类:MySQL 阅读:771 日期:2014-05-20

要注意两点。

1、不过版本要在5.0.37之后。

2、变量profiling是用户变量,每次都得重新启用。

mysql> set profiling=1;  

Query OK, 0 rows affected (0.00 sec)

mysql> select @@profiling;

+-------------+

| @@profiling |

+-------------+

|           1 |

+-------------+

1 row in set (0.01 sec)

mysql> select count(*) from t;

mysql> show profiles;

+----------+------------+------------------------+

| Query_ID | Duration   | Query                  |

+----------+------------+------------------------+

|        1 | 0.02717000 | show tables            |

|        2 | 0.74770100 | select count(*) from t |

+----------+------------+------------------------+

2 rows in set (0.00 sec)

mysql> show profile for query 2;

mysql> show profile block io,cpu for query 2;

mysql> show profile cpu,block io,memory,swaps,context switches,source for query 6;



十日谈技术博客

 

热门文章 更多>

微信扫一扫,关注技术十日谈