您的位置:首页 > 数据库

优化SQL语句的一般步骤①

2016-10-03 20:57 183 查看
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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: