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

这篇博客关注的是MySQL性能优化,尤其是Com_指标异常升高问题。作者指出,Com_的高比例可能意味着MySQL在处理请求时做了很多无效工作,消耗了大量系统资源。具体表现为change_db操作频繁,建议将mysql_db_query改为mysql_query以减少不必要的数据库切换。调整后,MySQL运行恢复正常。
摘要由CSDN通过智能技术生成

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 ___________________________________________________________

Total 14.46k 50.2/s

DMS 9.24k 32.1/s %Total: 63.90

QC Hits 3.66k 12.7/s 25.33

Com_ 1.04k 3.6/s 7.19

COM_QUIT 517 1.8/s 3.58

-Unknown 1 0.0/s 0.01

Slow 1 s 4 0.0/s 0.03 %DMS: 0.04 Log: OFF

DMS 9.24k 32.1/s 63.90

SELECT 9.21k 32.0/s 63.75 99.75

UPDATE 23 0.1/s 0.16 0.25

REPLACE 0 0/s 0.00 0.00

DELETE 0 0/s 0.00 0.00

INSERT 0 0/s 0.00 0.00

Com_ 1.04k 50/s 44.4

set_option 523 1.8/s 3.62

change_db 510 50/s 44.4

show_proces 5 0.0/s 0.03

__ SELECT and Sort _____________________________________________________

Scan 49 0.2/s %SELECT: 0.53

Range 16 0.1/s 0.17

Full join 2 0.0/s 0.02

Range check 0 0/s 0.00

Full rng join 0 0/s 0.00

Sort scan 55 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%

Hits 3.66k 12.7/s

Inserts 9.14k 31.8/s

Insrt:Prune 9.14k:1 31.8/s

Hit:Insert 0.40:1

__ Table Locks _________________________________________________________

Waited 0 0/s %Total: 0.00

Immediate 10.49k 36.4/s

__ Tables ______________________________________________________________

Open 58 of 512 %Cache: 11.33

Opened 64 0.2/s

__ Connections _________________________________________________________

Max used 4 of 2000 %Max: 0.20

Total 519 1.8/s

__ Created Temp ________________________________________________________

Disk table 1 0.0/s

Table 184 0.6/s Size: 256.0M

File 5 0.0/s

__ Threads _____________________________________________________________

Running 2 of 2

Cached 2 of 150 %Hit: 99.23

Created 4 0.0/s

Slow 0 0/s

__ Aborted _____________________________________________________________

Clients 0 0/s

Connects 0 0/s

__ Bytes _______________________________________________________________

Sent 20.36M 70.7k/s

Received 1.37M 4.7k/s

__ InnoDB Buffer Pool __________________________________________________

Usage 304.00k of 8.00M %Used: 3.71

Read hit 84.42%

Pages

Free 493 %Total: 96.29

Data 19 3.71 %Drty: 0.00

Misc 0 0.00

Latched 0.00

Reads 77 0.3/s

From file 12 0.0/s 15.58

Ahead Rnd 1 0.0/s

Ahead Sql 0 0/s

Writes 0 0/s

Flushes 0 0/s

Wait Free 0 0/s

__ InnoDB Lock _________________________________________________________

Waits 0 0/s

Current 0

Time acquiring

Total 0 ms

Average 0 ms

Max 0 ms

__ InnoDB Data, Pages, Rows ____________________________________________

Data

Reads 25 0.1/s

Writes 3 0.0/s

fsync 3 0.0/s

Pending

Reads 0

Writes 0

fsync 0

Pages

Created 0 0/s

Read 19 0.1/s

Written 0 0/s

Rows

Deleted 0 0/s

Inserted 0 0/s

Read 0 0/s

Updated 0 0/s

大家可以看到在Com_中占的比例是相当大的,而一般情况下,这个值应该是3.0%左右。如果这个值过高的话,就介绍,你的mysql处理请求中

做了一些无谓的工作,占用了大量的系统资源。其中我们看到尤为change_db的占用率比较高。这个值高了,介绍我们执行的user database;命令相当多。

检查程序,原来我们在执行查询语句的时候应用了mysql_query_db("database","sql");这个语句在每次执行的时候都会自动调用use database;

所以我们应该将mysql_db_query 更改成mysql_query();再观察mysql的运行状态,ok。一切正常了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值