博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
查看mysql语句运行时间
阅读量:5924 次
发布时间:2019-06-19

本文共 2911 字,大约阅读时间需要 9 分钟。

show profiles 之类的语句来查看

mysql> show profiles; Empty setmysql> show variables like "%pro%"; +---------------------------+-------+| Variable_name             | Value |+---------------------------+-------+| have_profiling            | YES   || profiling                 | OFF   || profiling_history_size    | 15    || protocol_version          | 10    || proxy_user                |       || slave_compressed_protocol | OFF   || stored_program_cache      | 256   |+---------------------------+-------+7 rows in set

profile是没有打开的

开启profile

mysql> set profiling=1; Query OK, 0 rows affectedmysql> show variables like "%pro%"; +---------------------------+-------+| Variable_name             | Value |+---------------------------+-------+| have_profiling            | YES   || profiling                 | ON    || profiling_history_size    | 15    || protocol_version          | 10    || proxy_user                |       || slave_compressed_protocol | OFF   || stored_program_cache      | 256   |+---------------------------+-------+7 rows in set

测试

执行几条sql语句

mysql> show profiles; +----------+------------+-----------------------------------------------------------------------+| Query_ID | Duration   | Query                                                                 |+----------+------------+-----------------------------------------------------------------------+|        1 |  0.0020095 | show variables like "%pro%"                                           ||        2 |  0.0012765 | select * from shop where shop_tradearea_id=14 and shop_fristtype=1001 ||        3 |   0.004761 | show tables                                                           ||        4 |  0.0360445 | show profile for query2                                               ||        5 | 0.00023675 | set profiling=1                                                       ||        6 | 0.36132975 | select * from account where type=4                                    |+----------+------------+-----------------------------------------------------------------------+6 rows in setmysql>  show profile for query 2; +----------------------+----------+| Status               | Duration |+----------------------+----------+| starting             | 0.000107 || checking permissions | 1.3E-5   || Opening tables       | 5E-5     || System lock          | 2.5E-5   || init                 | 0.000161 || optimizing           | 2.5E-5   || statistics           | 2.8E-5   || preparing            | 3E-5     || executing            | 4E-6     || Sending data         | 0.000536 || end                  | 1E-5     || query end            | 4E-6     || closing tables       | 1.4E-5   || freeing items        | 0.000242 || logging slow query   | 6E-6     || cleaning up          | 2.2E-5   |+----------------------+----------+

 

timestampdiff来查看测试时间

mysql> set @d=now(); mysql> select * from comment; mysql> select timestampdiff(second,@d,now());

 

转载地址:http://cxavx.baihongyu.com/

你可能感兴趣的文章
将VNC 安装在Centos 7步骤
查看>>
计算机与操作系统基础小结
查看>>
RabbitMQ详解(三)
查看>>
Oracle 12c应用连接VIP轮训负载均衡?
查看>>
Docker Network 配置,自定义bridge网络
查看>>
tomcat
查看>>
时任上海来伊份互联网事业群总裁王戈钧 :传统企业(线上+线下)移动互联网改造...
查看>>
限制nginx仅能域名访问,不可用ip访问
查看>>
linux之ps命令详解
查看>>
阿里云云计算ACP考试知识点(标红为重点)
查看>>
memcached安装和php扩展memcache安装
查看>>
中国版LinkedIn呼之欲出
查看>>
据廖雪峰python3教程----python学习第十三天
查看>>
UWP: 实现 UWP 应用自启动
查看>>
easyui 排序实现
查看>>
网站常见漏洞-- XSS攻击
查看>>
nginx+php
查看>>
Maven发布工程到私服
查看>>
centos 下安装man手册
查看>>
Docker 私有仓库的搭建
查看>>