查看mysql语句运行时间
show profiles 之类的语句来查看
mysql> show profiles;
Empty set mysql> show variables like "%pro%";
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| have_profiling | YES |
| profiling | OFF |
| profiling_history_size | |
| protocol_version | |
| proxy_user | |
| slave_compressed_protocol | OFF |
| stored_program_cache | |
+---------------------------+-------+
rows in set
profile是没有打开的
开启profile
mysql> set profiling=;
Query OK, rows affected mysql> show variables like "%pro%";
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| have_profiling | YES |
| profiling | ON |
| profiling_history_size | |
| protocol_version | |
| proxy_user | |
| slave_compressed_protocol | OFF |
| stored_program_cache | |
+---------------------------+-------+
rows in set
测试
执行几条sql语句
mysql> show profiles;
+----------+------------+-----------------------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+-----------------------------------------------------------------------+
| | 0.0020095 | show variables like "%pro%" |
| | 0.0012765 | select * from shop where shop_tradearea_id= and shop_fristtype= |
| | 0.004761 | show tables |
| | 0.0360445 | show profile for query2 |
| | 0.00023675 | set profiling= |
| | 0.36132975 | select * from account where type= |
+----------+------------+-----------------------------------------------------------------------+
rows in set mysql> show profile for query ;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| starting | 0.000107 |
| checking permissions | 1.3E-5 |
| Opening tables | 5E- |
| System lock | 2.5E-5 |
| init | 0.000161 |
| optimizing | 2.5E-5 |
| statistics | 2.8E-5 |
| preparing | 3E- |
| executing | 4E- |
| Sending data | 0.000536 |
| end | 1E- |
| query end | 4E- |
| closing tables | 1.4E-5 |
| freeing items | 0.000242 |
| logging slow query | 6E- |
| cleaning up | 2.2E-5 |
+----------------------+----------+
timestampdiff来查看测试时间
mysql> set @d=now();
mysql> select * from comment;
mysql> select timestampdiff(second,@d,now());
查看mysql语句运行时间的更多相关文章
- 查看mysql语句运行时间的2种方法
网站运行很慢的时候,我就特别起知道为什么这么慢,所以我查啊查,数据库绝对是很重要的一部分,里面运行的sql是绝对不能放过的.平时做项目的时候,我也会注意sql语句的书写,写出一些高效的sql来,所以我 ...
- 查看MySQL语句变量了多少行数据
explain MySQL语句 列如 explain SELECT * FROM 表名 WHERE id=1;
- MySQL Explain详解 查看mysql语句详情
在日常工作中,我们会有时会开慢查询去记录一些执行时间比较久的SQL语句,找出这些SQL语句并不意味着完事了,些时我们常常用到explain这个命令来查看一个这些SQL语句的执行计划,查看该SQL语句有 ...
- 查看Mysql实时执行的Sql语句
最近给客户开发了基于Asp.Net mvc5 +Mysql+EF的项目,但是在EF里无法看到Mysql执行的语句 之前也找到一些监控Mysql的软件但一直没有用起来,现在又遇到了问题即在EF里Mysa ...
- 查看语句运行时间异常的原因(SQLServer)
转载:http://www.cnblogs.com/fygh/archive/2012/01/17/2324926.html 查看语句运行时间异常的原因(SQLServer) 经常有开发同事反映如 ...
- MySQL查看SQL语句执行效率
Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看 SQL 语句的执行效 果,可以帮助选择更好的索引和优化查询语句,写出更好 ...
- 查看mysql中sql语句执行时间
查看mysql版本:select version();方法一: show profiles.1. Show profiles是5.0.37之后添加的,要想使用此功能,要确保版本在5.0.37之后. ...
- MySQL查看SQL语句执行效率(转)
Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看 SQL 语句的执行效 果,可以帮助选择更好的索引和优化查询语句,写出更好 ...
- 通过日志动态查看正在执行的mysql语句
通过日志动态查看正在执行的mysql语句 :tail -f /tmp/general_log.log
随机推荐
- Eclipse代码追踪功能说明
在使用Java编写复杂一些的程序时,你会不会常常对一层层的继承关系和一次次方法的调用感到迷惘呢?幸亏我们有了Eclipse这么好的IDE可以帮我们理清头绪--这就要使用Eclipse强大的代码追踪功能 ...
- 在把webpack作为本地开发依赖安装的时候报错
在把webpack作为本地开发依赖安装的时候报错 Refusing to install webpack as a dependency of itself 原因是package.json里的name ...
- 如何撰写PRD
PRD(Product-Requirement-Document,产品需求文档),这对于任何一个产品经理来说都不会陌生的一个文档,一个PRD是衡量一个产品经理整体思维的标准,一个PRD可以看出一个产品 ...
- http协议(四)http状态码
一:http状态码 表示客户端http请求的返回结果.标记服务器端的处理是否正常.通知出现的错误等工作 状态码的类别如下: http状态码种类繁多,大概有60多种,实际上经常使用的只有14种,下面为一 ...
- django复习笔记3:实战
1.初始化 2.配置后台,增加测试数据 3.测试urls/views/templates 4.增加静态资源 5.修改样式 6.模版继承 7.增加博文主页 8.增加表单 9.完善新增页面和编辑页面的表单 ...
- offline .net3.5
1.加载虚拟光驱 2.dism.exe /online /enable-feature /featurename:netfx3 /Source:D:\sources\sxs
- single-write-database-connection
http://ithare.com/ultimate-db-heresy-single-db-connection-part-i-performance-part-ii-scalability-to- ...
- 关于onbeforeunload的一些想法
页面在关闭前会有onbeforeUnload事件,来询问用户是否要关闭这个页面OR选项卡 浏览器的F5刷新为按下F5----onbeforeUnload----onunload----onload; ...
- Ros集成开发环境配置
参考资料: http://blog.csdn.net/yangziluomu/article/details/50848357 ROS使用IDE Eclipse http://blog.csdn.ne ...
- 利用mybatis-generator自动生成代码
mybatis-generator有三种用法:命令行.eclipse插件.maven插件.个人觉得maven插件最方便,可以在eclipse/intellij idea等ide上可以通用. 下面是从官 ...