查看mysql语句运行时间
mysql 查看 时间 运行 语句
2023-09-14 09:00:01 时间
show profiles 之类的语句来查看
mysql> show profiles; Empty set mysql> 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 affected mysql> 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 set mysql> 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());
相关文章
- Mysql授权允许远程访问解决Navicat for MySQL连接mysql提示客户端不支持服务器请求的身份验证协议;考虑升级MySQL客户端
- mysql乐观锁总结和实践
- 【MySql】mysql 慢日志查询工具之mysqldumpslow
- MySQL字段添加注释,但不改变字段的类型
- MySQL查看数据库相关信息
- MySQL选择数据库use与mysql_select_db使用详解
- Nginx配置WebService、MySQL、SQL Server、ORACLE等代理
- mysql启动时报错:Starting MySQL... ERROR! The server quit without updating PID file (/opt/mysql/data/mysql.pid) 的解决方法
- MySQL运维---延迟从库和半同步复制
- MYSQL错误解决:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
- mysql日志
- MySQL内核月报 2014.09-MariaDB· 性能优化·Extended Keys
- MySQL内核月报 2015.01-MySQL · 捉虫动态· mysql client crash一例
- MySql中json类型的使用___mybatis存取mysql中的json
- MySQL 批量插入数据,单次插入多少条数据效率最高
- 【收藏】windows下 Mysql 错误 Can‘t open and lock privilege tables: Table ‘mysql.user‘ doesn‘t exist
- mysql 查看数据库大小
- 解决MySQL Server Logs不能正常查看的问题
- MySQL用户权限(Host,User,Password)管理(mysql.user)
- Python MySQL - mysql-connector 驱动
- wait_timeout【Mysql】解决方案
- MySQL查看最大连接数和改动最大连接数
- Mysql 检查索引大小、表空间大小和表信息情况——筑梦之路
- 查看mysql连接情况,以及连接超时时间设置
- Mysql报错:Can't connect to local MySQL server through socket '/tmp/mysql.sock'
- Mysql之mysql工具
- MySQL基础篇 | 连接查询、子查询(嵌套)
- MySQL查看数据库状态命令详解