Home > Database > Mysql Tutorial > mysqlreport显示Com_中change_db占用比例高的问题的解决方法

mysqlreport显示Com_中change_db占用比例高的问题的解决方法

WBOY
Release: 2016-06-07 18:01:05
Original
992 people have browsed it

最近公司的mysql服务器经常出现阻塞状态。动不动就重启,给用户访问带来了相当的不便。

首先说明一点,每天的访问量并不大每天才2W的访问量,按道理说,访问量再增加一倍这样的服务器也应该足以承受。可是我们的服务器为什么总是这样频频重启呢?经过mysqlreport显示mysql运行的状态如下:
<pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><font color="#006bad">MySQL 5.1.28-rc-log   uptime 0 0:4:48    Thu Apr 30 14:04:58 2009<br><br>__ Key _________________________________________________________________<br>Buffer used   7.74M of 384.00M %Used:  2.02<br> Current   52.89M      %Usage: 13.77<br>Write hit    0.00%<br>Read hit    91.97%<br><br>__ Questions ___________________________________________________________<br>Total     14.46k  50.2/s<br> DMS      9.24k  32.1/s %Total: 63.90<br> QC Hits    3.66k  12.7/s      25.33<br> Com_     1.04k   3.6/s      7.19<br> COM_QUIT    517   1.8/s      3.58<br> -Unknown     1   0.0/s      0.01<br>Slow 1 s      4   0.0/s      0.03 %DMS:  0.04 Log: OFF<br>DMS       9.24k  32.1/s      63.90<br> SELECT    9.21k  32.0/s      63.75     99.75<br> UPDATE      23   0.1/s      0.16     0.25<br> REPLACE      0    0/s      0.00     0.00<br> DELETE      0    0/s      0.00     0.00<br> INSERT      0    0/s      0.00     0.00<br>Com_      1.04k   50/s      44.4<br> set_option   523   1.8/s      3.62<br> change_db    510   50/s      44.4<br> show_proces    5   0.0/s      0.03<br><br>__ SELECT and Sort _____________________________________________________<br>Scan        49   0.2/s %SELECT:  0.53<br>Range       16   0.1/s      0.17<br>Full join      2   0.0/s      0.02<br>Range check     0    0/s      0.00<br>Full rng join    0    0/s      0.00<br>Sort scan     55   0.2/s<br>Sort range    475   1.6/s<br>Sort mrg pass    0    0/s<br><br>__ Query Cache _________________________________________________________<br>Memory usage  12.02M of 150.00M %Used:  8.01<br>Block Fragmnt  0.01%<br>Hits      3.66k  12.7/s<br>Inserts     9.14k  31.8/s<br>Insrt:Prune  9.14k:1  31.8/s<br>Hit:Insert   0.40:1<br><br>__ Table Locks _________________________________________________________<br>Waited       0    0/s %Total:  0.00<br>Immediate   10.49k  36.4/s<br><br>__ Tables ______________________________________________________________<br>Open        58 of 512  %Cache: 11.33<br>Opened       64   0.2/s<br><br>__ Connections _________________________________________________________<br>Max used      4 of 2000   %Max:  0.20<br>Total       519   1.8/s<br><br>__ Created Temp ________________________________________________________<br>Disk table     1   0.0/s<br>Table       184   0.6/s  Size: 256.0M<br>File        5   0.0/s<br><br>__ Threads _____________________________________________________________<br>Running       2 of  2<br>Cached       2 of 150   %Hit: 99.23<br>Created       4   0.0/s<br>Slow        0    0/s<br><br>__ Aborted _____________________________________________________________<br>Clients       0    0/s<br>Connects      0    0/s<br><br>__ Bytes _______________________________________________________________<br>Sent      20.36M  70.7k/s<br>Received    1.37M  4.7k/s<br><br>__ InnoDB Buffer Pool __________________________________________________<br>Usage     304.00k of  8.00M %Used:  3.71<br>Read hit    84.42%<br>Pages<br> Free      493      %Total: 96.29<br> Data       19           3.71 %Drty:  0.00<br> Misc       0           0.00<br> Latched                 0.00<br>Reads       77   0.3/s<br> From file    12   0.0/s      15.58<br> Ahead Rnd     1   0.0/s<br> Ahead Sql     0    0/s<br>Writes       0    0/s<br>Flushes       0    0/s<br>Wait Free      0    0/s<br><br>__ InnoDB Lock _________________________________________________________<br>Waits        0    0/s<br>Current       0<br>Time acquiring<br> Total       0 ms<br> Average      0 ms<br> Max        0 ms<br><br>__ InnoDB Data, Pages, Rows ____________________________________________<br>Data<br> Reads      25   0.1/s<br> Writes      3   0.0/s<br> fsync       3   0.0/s<br> Pending<br>  Reads      0<br>  Writes     0<br>  fsync      0<br><br>Pages<br> Created      0    0/s<br> Read       19   0.1/s<br> Written      0    0/s<br><br>Rows<br> Deleted      0    0/s<br> Inserted     0    0/s<br> Read       0    0/s<br> Updated      0    0/s<br>大家可以看到在Com_中占的比例是相当大的,而一般情况下,这个值应该是3.0%左右。如果这个值过高的话,就说明,你的mysql处理请求中<br>做了一些无谓的工作,占用了大量的系统资源。其中我们看到尤为change_db的占用率比较高。这个值高了,说明我们执行的user database;命令相当多。<br>检查程序,原来我们在执行查询语句的时候应用了mysql_query_db("database","sql");这个语句在每次执行的时候都会自动调用use database;<br>所以我们应该将mysql_db_query 更改成mysql_query();再观察mysql的运行状态,ok。一切正常了。</font>
Copy after login
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