mysql sql语句执行时间查询
2016-05-04 10:15
585 查看
[b][b]第一种:show profiles 之类的语句来查看[/b][/b]
1.查一下profile是不是打开了,默认是不打开的。
我查看一下profiles里面没有东西,所以公司的电脑里面profile是没有打开的,我查看了一下mysql变量,果然是OFF的。
2.开启profile
eg:
第二种:(通过时间差查看)
1.查一下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)
我查看一下profiles里面没有东西,所以公司的电脑里面profile是没有打开的,我查看了一下mysql变量,果然是OFF的。
2.开启profile
mysql> set profiling=1; Query OK, 0 rows affected (0.00 sec)
eg:
mysql> select * from test_1; mysql> show profiles; +----------+------------+----------------------+ | Query_ID | Duration | Query | +----------+------------+----------------------+ | 1 | 0.84718100 | select * from test_1 | +----------+------------+----------------------+ 1 row in set (0.00 sec)
第二种:(通过时间差查看)
delimiter // set @d=now(); select * from comment; select timestampdiff(second,@d,now()); delimiter ; Query OK, 0 rows affected (1 min 55.58 sec) +----------------------------------+ | timestampdiff(second, @d, now()) | +----------------------------------+ | 2 | +----------------------------------+ 1 row in set (1 min 55.58 sec)
相关文章推荐
- MySQL的Order By Rand()的效率问题
- mysql 之PDO连接方式
- 【MySQL笔记】: unable to connect to remote host. catalog download has failed.
- 如何在MySQL存储过程中保留注释
- MYSQL之union和order by分析([Err] 1221 - Incorrect usage of UNION and ORDER BY)
- 一个最不可思议的 MySQL 死锁分析
- MySQL 加锁处理分析
- mysql关于or的索引问题
- MySQL中in(常量列表)的执行计划
- MySQL(免安装版)下载安装、配置与使用(win7x64)
- MySQL分库分表的技巧
- MySQL分库分表的技巧
- 使用 MySQL 查找附近的位置
- mysql 登录、退出
- MySQL数据库优化学习笔记
- MySQL 存储过程
- MySQL_Character_Setting
- MySQL_Aggregate_Functions
- ubuntu用ppa安装mysql并配置远程连接
- mysql5.6.29添加慢查询sql日志