频道栏目
首页 > 资讯 > MySQL > 正文

mysql怎么查看sql的执行频率?

18-02-14        来源:[db:作者]  
收藏   我要投稿

7.1 查看sql的执行频率

show 【session|global】 status;

实验一:查询自本次登陆以来的数据库操作,主要关心值的获取

mysql> show session status like 'Com_insert%';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| Com_insert        | 0     |
| Com_insert_select | 0     |
+-------------------+-------+
2 rows in set (0.00 sec)

mysql> show session status like 'Com_select%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select    | 43    |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show session status like 'Com_update%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Com_update       | 0     |
| Com_update_multi | 0     |
+------------------+-------+
2 rows in set (0.00 sec)

mysql> show session status like 'Com_delete%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Com_delete       | 4     |
| Com_delete_multi | 0     |
+------------------+-------+
2 rows in set (0.00 sec)

实验二:查询自数据库服务启动以来的数据库操作,主要关心值的获取

mysql> show global status like 'Com_delete%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Com_delete       | 7     |
| Com_delete_multi | 0     |
+------------------+-------+
2 rows in set (0.00 sec)

mysql> show global status like 'Com_insert%';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| Com_insert        | 8     |
| Com_insert_select | 7     |
+-------------------+-------+
2 rows in set (0.00 sec)

mysql> show global status like 'Com_update%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Com_update       | 0     |
| Com_update_multi | 0     |
+------------------+-------+
2 rows in set (0.00 sec)

mysql> show global status like 'Com_select%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select    | 139   |
+---------------+-------+
1 row in set (0.00 sec)

实验三:查询自数据库innodb引擎的数据库操作,主要关心值的获取的是影响的行数

mysql> show session status like 'InnoDB_rows%';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Innodb_rows_deleted  | 2     |
| Innodb_rows_inserted | 4     |
| Innodb_rows_read     | 27    |
| Innodb_rows_updated  | 0     |
+----------------------+-------+
4 rows in set (0.00 sec)

mysql> show global status like 'InnoDB_rows%';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Innodb_rows_deleted  | 2     |
| Innodb_rows_inserted | 4     |
| Innodb_rows_read     | 27    |
| Innodb_rows_updated  | 0     |
+----------------------+-------+
4 rows in set (0.00 sec)

实验四:查看数据库的链接次数包含成功与不成功

mysql> show global status like 'connections';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections   | 8     |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show session status like 'connections';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections   | 8     |
+---------------+-------+
1 row in set (0.00 sec)

实验五:查看数据库的工作的时间秒数

mysql> show session status like 'Uptime';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Uptime        | 25002 |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show global status like 'Uptime';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Uptime        | 25014 |
+---------------+-------+
1 row in set (0.00 sec)

实验六:查看数据库的满查询的次数

mysql> show global status like 'Slow_queries';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Slow_queries  | 0     |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show session status like 'Slow_queries';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Slow_queries  | 0     |
+---------------+-------+
1 row in set (0.00 sec)
相关TAG标签
上一篇:数据源RecordSource和数据集RecordSet的关系讲解
下一篇:MongoDB基础学习--环境搭建及使用技巧
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站