MySQL怎么看用户sql执行次数_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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值