mysql 查看sql的执行频率

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)

猜你喜欢

转载自blog.csdn.net/shan_zhi_jun/article/details/79322395