首页 > 数据库 > MySQL > 正文

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

2024-07-24 13:04:18
字体:
来源:转载
供稿:网友
首先说明一点,每天的访问量并不大每天才2W的访问量,按道理说,访问量再增加一倍这样的服务器也应该足以承受。可是我们的服务器为什么总是这样频频重启呢?经过mysqlreport显示mysql运行的状态如下:MySQL 5.1.28-rc-log uptime 0 0:4:48 Thu Apr 30 14:04:58 2009

__ Key _________________________________________________________________
Buffer used 7.74M of 384.00M %Used: 2.02
Current 52.89M%Usage: 13.77
Write hit 0.00%
Read hit 91.97%

__ Questions ___________________________________________________________
Total14.46k 50.2/s
DMS9.24k 32.1/s %Total: 63.90
QC Hits 3.66k 12.7/s25.33
Com_1.04k 3.6/s7.19
COM_QUIT 517 1.8/s3.58
-Unknown1 0.0/s0.01
Slow 1 s4 0.0/s0.03 %DMS: 0.04 Log: OFF
DMS9.24k 32.1/s63.90
SELECT 9.21k 32.0/s63.7599.75
UPDATE23 0.1/s0.160.25
REPLACE0 0/s0.000.00
DELETE0 0/s0.000.00
INSERT0 0/s0.000.00
Com_1.04k 50/s44.4
set_option 523 1.8/s3.62
change_db 510 50/s44.4
show_proces 5 0.0/s0.03

__ SELECT and Sort _____________________________________________________
Scan49 0.2/s %SELECT: 0.53
Range16 0.1/s0.17
Full join2 0.0/s0.02
Range check0 0/s0.00
Full rng join 0 0/s0.00
Sort scan55 0.2/s
Sort range 475 1.6/s
Sort mrg pass 0 0/s

__ Query Cache _________________________________________________________
Memory usage 12.02M of 150.00M %Used: 8.01
Block Fragmnt 0.01%
Hits3.66k 12.7/s
Inserts9.14k 31.8/s
Insrt:Prune 9.14k:1 31.8/s
Hit:Insert 0.40:1

__ Table Locks _________________________________________________________
Waited0 0/s %Total: 0.00
Immediate 10.49k 36.4/s

__ Tables ______________________________________________________________
Open58 of 512 %Cache: 11.33
Opened64 0.2/s

__ Connections _________________________________________________________
Max used4 of 2000 %Max: 0.20
Total519 1.8/s

__ Created Temp ________________________________________________________
Disk table1 0.0/s
Table184 0.6/s Size: 256.0M
File5 0.0/s

__ Threads _____________________________________________________________
Running2 of 2
Cached2 of 150 %Hit: 99.23
Created4 0.0/s
Slow0 0/s

__ Aborted _____________________________________________________________
Clients0 0/s
Connects0 0/s

__ Bytes _______________________________________________________________
Sent20.36M 70.7k/s
Received 1.37M 4.7k/s

__ InnoDB Buffer Pool __________________________________________________
Usage304.00k of 8.00M %Used: 3.71
Read hit 84.42%
Pages
Free493%Total: 96.29
Data193.71 %Drty: 0.00
Misc00.00
Latched0.00
Reads77 0.3/s
From file 12 0.0/s15.58
Ahead Rnd1 0.0/s
Ahead Sql0 0/s
Writes0 0/s
Flushes0 0/s
Wait Free0 0/s

__ InnoDB Lock _________________________________________________________
Waits0 0/s
Current0
Time acquiring
Total0 ms
Average0 ms
Max0 ms

__ InnoDB Data, Pages, Rows ____________________________________________
Data
Reads25 0.1/s
Writes3 0.0/s
fsync3 0.0/s
Pending
Reads0
Writes0
fsync0

Pages
Created0 0/s
Read19 0.1/s
Written0 0/s

Rows
Deleted0 0/s
Inserted0 0/s
Read0 0/s
Updated0 0/s
大家可以看到在Com_中占的比例是相当大的,而一般情况下,这个值应该是3.0%左右。如果这个值过高的话,就说明,你的mysql处理请求中
做了一些无谓的工作,占用了大量的系统资源。其中我们看到尤为change_db的占用率比较高。这个值高了,说明我们执行的user database;命令相当多。
检查程序,原来我们在执行查询语句的时候应用了mysql_query_db("database","sql");这个语句在每次执行的时候都会自动调用use database;
所以我们应该将mysql_db_query 更改成mysql_query();再观察mysql的运行状态,ok。一切正常了。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表