查看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
随机推荐
- 转: YAML 语言教程 from(阮一峰)
YAML 语言教程 from: http://www.ruanyifeng.com/blog/2016/07/yaml.html
- Python的高级特性4:函数式编程
函数式编程的核心就是把函数当成对象来进行编程. 有两个常用到的方法:map/reduce,filter,其中map和filter是内建方法,而reduce不是,所以需要import相关模块. map接 ...
- PL/SQL Developer 11 64bit 安装和配置
安装后, 1. 解压 instant client 到plsql developer 的安装目录 注意, 此版本只支持 instantclient_11_x, 不支持 instantclient ...
- 轉發XML
Delphi 中的 XMLDocument 类详解(3) - 读取 xml 文件 先虚拟一个测试文件: test.xml; 放在 c:\temp\ 下备用. <?xml version=&quo ...
- ListView实现原理
转载:http://blog.csdn.net/guolin_blog/article/details/44996879 在Android所有常用的原生控件当中,用法最复杂的应该就是ListView了 ...
- Dynamics CRM 2016 的新特性
新版本CRM (2016 with update 0.1) 发布已有几个月了,总结一下新特性,从几个方面来看: 1. 针对整合功能的新特性 (1) 增加了CRM App for Outlook. 这个 ...
- ASP.NET 中执行 URL 重写
具体实现步骤(其中的一种实现方法): 一.下载相关的DLL(ActionlessForm.dll和UrlRewriter.dll) http://download.csdn.net/detail/yi ...
- 拒绝了对对象 'XXX' (数据库 'XXX',架构 'dbo')的 SELECT 权限
2010-04-17 23:16 在IIS里测试ASP.NET网站时会遇到这样的问题(ASP.NET+SQL2005)我自己的解决方法是这样的: 1.打开SQL2005管理界面(没有安装SQLServ ...
- scala 学习笔记(02) 元组Tuple、数组Array、Map、文件读写、网页抓取示例
package yjmyzz import java.io.PrintWriter import java.util.Date import scala.io.Source object ScalaA ...
- jboss上的soap web service开发示例
以下示例,由jboss quickstart示例代码得来: 一.创建一个常规的dynamic web项目,建议支持maven ,项目的关键属性参考下图: 二.定义服务接口及参数对象 HelloWorl ...