Home > Database > Mysql Tutorial > mysql提示Writing to net解决_MySQL

mysql提示Writing to net解决_MySQL

WBOY
Release: 2016-06-01 13:34:07
Original
1061 people have browsed it

bitsCN.com

mysql提示Writing to net解决

 

最近发现某一个数据库cpu占用比较过。超过200%了。

首先查看数据库慢日志,设定慢日志5秒,基本上没有产生日,没有超过5秒的语句。

show processlist;

 

后发现几条select有几个表查询需要1-2秒,

explain select * from xxx ,发现没有走索引,全表扫描,以前数据量少那会很快就出来了,目前查询总数据都在2万以内,现在数据量大了,其它表都1000w级了,以前只优化了大表的索引,所以问题就突出了。索引建完后CPU明显示下降,据我了解,msyql   cpu占用高,80%的情况未使用索引有关。

 

在次show processlist

发现多条语句状态为Writing to net

通过分析基本都是select 语句,都是查询数据太数据库返回网络回写不赢,

查看show global variables like "global max_allowed_packet"  只有1M

 

通过增加缓存

set global max_allowed_packet =134217728

 

问题得到解决!原因是多条select 返回数据越过缓存超过默认设置。

 

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template