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语句运行时间的更多相关文章

  1. 查看mysql语句运行时间的2种方法

    网站运行很慢的时候,我就特别起知道为什么这么慢,所以我查啊查,数据库绝对是很重要的一部分,里面运行的sql是绝对不能放过的.平时做项目的时候,我也会注意sql语句的书写,写出一些高效的sql来,所以我 ...

  2. 查看MySQL语句变量了多少行数据

    explain MySQL语句 列如 explain SELECT * FROM 表名 WHERE id=1;

  3. MySQL Explain详解 查看mysql语句详情

    在日常工作中,我们会有时会开慢查询去记录一些执行时间比较久的SQL语句,找出这些SQL语句并不意味着完事了,些时我们常常用到explain这个命令来查看一个这些SQL语句的执行计划,查看该SQL语句有 ...

  4. 查看Mysql实时执行的Sql语句

    最近给客户开发了基于Asp.Net mvc5 +Mysql+EF的项目,但是在EF里无法看到Mysql执行的语句 之前也找到一些监控Mysql的软件但一直没有用起来,现在又遇到了问题即在EF里Mysa ...

  5. 查看语句运行时间异常的原因(SQLServer)

    转载:http://www.cnblogs.com/fygh/archive/2012/01/17/2324926.html 查看语句运行时间异常的原因(SQLServer)   经常有开发同事反映如 ...

  6. MySQL查看SQL语句执行效率

    Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看 SQL 语句的执行效 果,可以帮助选择更好的索引和优化查询语句,写出更好 ...

  7. 查看mysql中sql语句执行时间

    查看mysql版本:select version();方法一: show profiles.1. Show profiles是5.0.37之后添加的,要想使用此功能,要确保版本在5.0.37之后.  ...

  8. MySQL查看SQL语句执行效率(转)

    Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看 SQL 语句的执行效 果,可以帮助选择更好的索引和优化查询语句,写出更好 ...

  9. 通过日志动态查看正在执行的mysql语句

    通过日志动态查看正在执行的mysql语句 :tail -f /tmp/general_log.log

随机推荐

  1. python反弹tty shell

    linux环境下进行内外渗透需要反弹shell连接内网ssh,Telnet等,就需要tty层的shell了.python代码转过来的,备用. #!/usr/bin/python import sys ...

  2. HTML 学习笔记 CSS3 (多列)

    CSS3多列 通过CSS3 我们能够创建多个列来对文本进行布局. 在这篇文章中 你将了解到如下多列属性: column-count column-gap column-rule 浏览器支持: 多列的属 ...

  3. JS常用自定义方法

    1,JS生成随机数方法 getRandom(100),表示生成0-100的数 function getRandom(n){ return Math.floor(Math.random()*n+1) } ...

  4. 阿里云Centos 6.3 64位 安全加固版 升级 Php 中的 Curl 7.19 到 7.35

    *注意是使用阿里云一键安装包的升级,升级前快照备份哟,小伙伴! 1.SSH远程到root下下载新版本curl 网址地址:http://curl.haxx.se/download.html 完成curl ...

  5. Linux Linux程序练习十四(多进程压力测试)

    /* * 题目: * 编程一个基本多进程测试框架,提示用户输入进程数.和每个进程数运行圈数.(fork) * 进行多进程压力测试.(execve) * 要求父进程能监控所有子进程的退出,避免僵尸进程. ...

  6. asp中的md5/sha1/sha256算法收集

    对于asp这种古董级的技术,这年头想找一些有用的资料已经不容易了,下面是一些常用的加密算法: md5 (将以下代码另存为md5.inc) <% Private Const BITS_TO_A_B ...

  7. ubuntu15.10 或者 16.04 或者 ElementryOS 下使用 Dotnet Core

    这里我们不讲安装,缺少libicu52自行安装. 安装完成后使用dotnet restore或者build都会失败,一是报编译的dll不适合当前系统,二是编译到ubuntu16.04文件夹下会产生一些 ...

  8. Notes on Convolutional Neural Networks

    这是Jake Bouvrie在2006年写的关于CNN的训练原理,虽然文献老了点,不过对理解经典CNN的训练过程还是很有帮助的.该作者是剑桥的研究认知科学的.翻译如有不对之处,还望告知,我好及时改正, ...

  9. JavaScript中call,apply,bind方法的总结。

    why?call,apply,bind干什么的?为什么要学这个? 一般用来指定this的环境,在没有学之前,通常会有这些问题. var a = { user:"追梦子", fn:f ...

  10. MPLS

    Multiprotocol Label Switching From Wikipedia, the free encyclopedia "MPLS" redirects here. ...