查看mysql语句运行时间
通过 show profiles 语句来查看
查一下profile是不是打开了,默认是不打开的。
mysql> show profiles; Empty set (0.02 sec) mysql> show variables like "%pro%"; +---------------------------+-------+ | Variable_name | Value | +---------------------------+-------+ | profiling | OFF | | profiling_history_size | 15 | | protocol_version | 10 | | slave_compressed_protocol | OFF | +---------------------------+-------+ 4 rows in set (0.00 sec)
开启profile
mysql> set profiling=1; Query OK, 0 rows affected (0.00 sec)
测试
mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | aa | | bb | | comment | | string_test | | user | +----------------+ 5 rows in set (0.00 sec) mysql> select * from aa; +----+------+------------+------+ | id | name | nname | sex | +----+------+------------+------+ | 2 | tank | bbbb,4bbbb | NULL | | 3 | zhang| 3,c,u | NULL | +----+------+------------+------+ 2 rows in set (0.00 sec) mysql> update aa set name='d'; Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql> delete from bb; Query OK, 2 rows affected (0.00 sec) mysql> show profiles; +----------+------------+------------------------+ | Query_ID | Duration | Query | +----------+------------+------------------------+ | 1 | 0.00054775 | show tables | | 2 | 0.00022400 | select * from aa | | 3 | 0.00026275 | update aa set name='d' | | 4 | 0.00043000 | delete from bb | +----------+------------+------------------------+ 4 rows in set (0.00 sec) mysql> show profile; +----------------------+-----------+ | Status | Duration | +----------------------+-----------+ | (initialization) | 0.0000247 | | checking permissions | 0.0000077 | | Opening tables | 0.0000099 | | System lock | 0.000004 | | Table lock | 0.000005 | | init | 0.0003057 | | query end | 0.0000062 | | freeing items | 0.000057 | | closing tables | 0.000008 | | logging slow query | 0.0000015 | +----------------------+-----------+ 10 rows in set (0.00 sec) mysql> show profile for query 1; +----------------------+-----------+ | Status | Duration | +----------------------+-----------+ | (initialization) | 0.000028 | | checking permissions | 0.000007 | | Opening tables | 0.0000939 | | System lock | 0.0000017 | | Table lock | 0.0000055 | | init | 0.000009 | | optimizing | 0.0000027 | | statistics | 0.0000085 | | preparing | 0.0000065 | | executing | 0.000004 | | checking permissions | 0.000258 | | Sending data | 0.000049 | | end | 0.0000037 | | query end | 0.0000027 | | freeing items | 0.0000307 | | closing tables | 0.0000032 | | removing tmp table | 0.0000275 | | closing tables | 0.0000037 | | logging slow query | 0.000002 | +----------------------+-----------+ 19 rows in set (0.00 sec) mysql> show profile for query 3; +----------------------+-----------+ | Status | Duration | +----------------------+-----------+ | (initialization) | 0.0000475 | | checking permissions | 0.0000077 | | Opening tables | 0.000026 | | System lock | 0.0000042 | | Table lock | 0.0000045 | | init | 0.0000205 | | Updating | 0.0000787 | | end | 0.0000567 | | query end | 0.000004 | | freeing items | 0.0000067 | | closing tables | 0.000004 | | logging slow query | 0.000002 | +----------------------+-----------+ 12 rows in set (0.00 sec)
查看mysql语句运行时间相关推荐
- 查看mysql语句运行时间的方法
set @d=now(); select * from comment; select timestampdiff(second,@d,now());为了验证select 1 与 select 1 f ...
- 查看mysql语句运行时间的2种方法
http://www.jb51.net/article/45185.htm 网站运行很慢的时候,我就特别起知道为什么这么慢,所以我查啊查,数据库绝对是很重要的一部分,里面运行的sql是绝对不能放过的. ...
- mysql解析运行时间_分析 MySQL 语句运行时间
为了验证select 1 与 select 1 from tableName 与 select * from tableName的执行效率,需要测试一下各自执行的时间.于是总结一下,查看mysql语句 ...
- MySQL之怎么查看MySQL语句有没有用到索引
文章目录 MySQL之怎么查看MySQL语句有没有用到索引 MySQL之怎么查看MySQL语句有没有用到索引 通过explain,如以下例子: EXPLAIN SELECT * FROM employ ...
- explain查看mysql语句的执行效率
命中率 索引组织表 mysql 5.5.42的版本写法如下所示: EXPLAIN EXTENDED/EXPLAIN sql show WARNINGS; mysql 8.0.16的版本写法如下所示: ...
- mysql执行语句_实时查看MySQL执行的语句
我们在追查MySQL问题和性能调优时,有时希望看到当前都有哪些命令正在被执行,让我们迅速找到热点命令.下面我们就来介绍下如何查看当前正在执行的MySQL语句. 日志LOG 我们之前在 用service ...
- MySQL查看SQL语句执行效率和mysql几种性能测试的工具
Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看 SQL 语句的执行效 果,可以帮助选择更好的索引和优化查询语句,写出更好 ...
- 怎么查看mysql正在运行的语句_MySQL如何查询当前正在运行的SQL语句
通过status命令,查看Slow queries这一项,如果值长时间>0,说明有查询执行时间过长 以下为引用的内容: mysql> status; -------------- mysq ...
- mysql 压力测试知乎_MySQL查看SQL语句执行效率和mysql几种性能测试的工具
网络中整理,记录下,朋友们应该用得到! Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看 SQL 语句的执行效 果,可以帮 ...
最新文章
- ES5-Array-join
- FlushMode属性与transaction(spring注入的事务)
- Linux各发行版本之间的比较
- ElasticSearch(一)基础知识
- redis memcache 性能比较
- ncl 添加点shp文件_基于Arcgis绘制采样点地图
- Matlab之程序的暂停与中止
- RHadoop的技术性文章
- 二进制、十进制和16进制对照表以及对应的字符
- 【原理+代码】Python实现Topsis分析法(优劣解距离法)
- Echarts实现区级行政区划地图
- java根据距离算经纬度_java 根据两点经纬度来算距离
- 计算机时代前的发明,假如1万人回到150万年前,只带简单工具,多久才能制造出计算机?...
- Java高级技术FastDFS的学习
- 前端面试题之 对Promise的理解
- 三个灭点来衡量一个立方体
- Multiple View Geometry(多视图几何)学习笔记(23)—射影摄像机对二次曲面的作用摄像机中心的重要性
- iOS10.3后允许App运行中变更App图标
- 使用instantclient_19客户端(免安装)远程连接Oracle服务器端数据库
- 10w 行级别数据的 Excel 导入,完整优化记录
热门文章
- 目前最常用的计算机机箱类型为_绍兴承接离心风机箱高品质
- mysql connect返回值_mysql_connect
- cad java_cad和java哪个工资高
- 设计用例测试下面的python程序def do_你能变形python的unittest测试用例吗?
- python 2x和python 3x的区别_python2x和3x区别
- unittest所有断言方法
- 使用maven时报错Dynamic Web Module 3.1 requires Java 1.7 or newe
- php-常量、运算符
- 【bzoj1597】 土地购买
- Linux CentOS 6.5 + Apache + Mariadb + PHP环境搭建