怎么使用MySQL profile


本篇内容主要讲解“怎么使用MySQL profile”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么使用MySQL profile”吧!剖析单条查询 profile:

mysql> show variables like ‘%prof%’;
+————————+——-+
| Variable_name | Value |
+————————+——-+
| have_profiling | YES |
| profiling | OFF |
| profiling_history_size | 15 |
+————————+——-+
3 rows in set (0.00 sec)

mysql> setprofiling = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show variables like ‘%prof%’;
+————————+——-+
| Variable_name | Value |
+————————+——-+
| have_profiling | YES |
| profiling | ON |
| profiling_history_size | 15 |
+————————+——-+
3 rows in set (0.00 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a 开发云主机域名quicker startup with -A

Database changed
mysql> select count(*) from user;
+———-+
| count(*) |
+———-+
| 4 |
+———-+
1 row in set (0.03 sec)

mysql> show profiles;
+———-+————+——————————+
| Query_ID | Duration | Query |
+———-+————+——————————+
| 1 | 0.00103425 | show variables like ‘%prof%’ |
| 2 | 0.00016325 | SELECT DATABASE() |
| 3 | 0.00049450 | show databases |
| 4 | 0.00039775 | show tables |
| 5 | 0.02702100 | select count(*) from user |
+———-+————+——————————+
5 rows in set, 1 warning (0.00 sec)

mysql> show profile for query 5;
+———————-+———-+
| Status | Duration |
+———————-+———-+
| starting | 0.000090 |
| checking permissions | 0.000012 |
| Opening tables | 0.000030 |
| init | 0.000035 |
| System lock | 0.000016 |
| optimizing | 0.025417 |
| executing | 0.000054 |
| end | 0.000551 |
| query end | 0.000020 |
| closing tables | 0.000021 |
| freeing items | 0.000732 |
| cleaning up | 0.000045 |
+———————-+———-+
12 rows in set, 1 warning (0.00 sec)
到此,相信大家对“怎么使用MySQL profile”有了更深的了解,不妨来实际操作一番吧!这里是开发云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

相关推荐: mysql 锁分析相关命令

1.服务器级别的锁等待 可以通过show (full) processlist看到等待锁的线程id,但是无法知道究竟哪个线程持有锁 可以通过mysqladmin debug 相关等待锁的线程以及谁持有锁可以在错误日志中找到 2.存储引擎层的锁等待则比较麻烦,以…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 06/27 22:06
下一篇 06/27 22:07

相关推荐