设为首页 加入收藏

TOP

使用Profiles分析SQL语句执行时间和消耗资源
2015-11-21 01:42:33 来源: 作者: 【 】 浏览:0
Tags:使用 Profiles分析 SQL 语句 执行 时间 消耗 资源

打开profiling,默认是没开启的.

mysql> set profiling=1;

执行要分析的SQL语句

mysql> select count(1) from wechat_employee,Employee;

显示profiles表

mysql> show profiles;

查询结果:

+----------+------------+-----------------------------------------------+ | Query_ID | Duration | Query | +----------+------------+-----------------------------------------------+ | 1 | 0.00072975 | select count(1) from wechat_employee,Employee | | 2 | 0.00028450 | set profiling=1 | | 3 | 0.00324875 | select count(1) from wechat_employee,Employee | +----------+------------+-----------------------------------------------+ 

查询详细信息:

show profile cpu,block io for query 3; 

结果:

+--------------------------------+----------+----------+------------+--------------+---------------+ | Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out | +--------------------------------+----------+----------+------------+--------------+---------------+ | starting | 0.000041 | 0.000000 | 0.000000 | 0 | 0 | | Waiting for query cache lock | 0.000073 | 0.000000 | 0.000000 | 0 | 0 | | checking query cache for query | 0.000025 | 0.000000 | 0.000000 | 0 | 0 | | checking privileges on cached | 0.000023 | 0.000000 | 0.000000 | 0 | 0 | | checking permissions | 0.000018 | 0.000000 | 0.000000 | 0 | 0 | | checking permissions | 0.000012 | 0.000000 | 0.000000 | 0 | 0 | | sending cached result to clien | 0.003009 | 0.000000 | 0.004000 | 0 | 0 | | logging slow query | 0.000032 | 0.000000 | 0.000000 | 0 | 0 | | cleaning up | 0.000018 | 0.000000 | 0.000000 | 0 | 0 | +--------------------------------+----------+----------+------------+--------------+---------------+ 9 rows in set (0.00 sec) 

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇SQL优化--逻辑优化--非SPJ优化 下一篇SqlServiceInsert时返回插入的主键

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: