优化SQL语句的一般步骤①


1.通过show status命令了解各种sql执行的频率。

格式:mysql>show [session|global] status;
其中:session(默认)表示当前连接
global 表示自数据库启动至今
相关操作:
mysql>show status;
mysql>show global status;
mysql>show status like 'Com_%';
mysql>show global status like 'Com_%';
截图:展示数据库的各种状态

一般查看以Com_开头的
查看增删改查的总数
show global status like 'Com_insert';
show global status like 'Com_update';
show global status like 'Com_select';
show global status like 'Com_delete';
截图:
查看Innodb引擎表受影响的行数:
mysql> show global status like 'innodb_rows%';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| Innodb_rows_deleted | 0 |
| Innodb_rows_inserted | 12 |
| Innodb_rows_read | 78 |
| Innodb_rows_updated | 0 |
+----------------------+-------+
4 rows in set (0.00 sec)

查看连接总次数
mysql> show global status like 'connections';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections | 2865 |
+---------------+-------+
1 row in set (0.00 sec)

服务器已经工作的秒数:
mysql> show global status like 'uptime';
+---------------+--------+
| Variable_name | Value |
+---------------+--------+
| Uptime | 515199 |
+---------------+--------+
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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值