最近開(kāi)發(fā)的產(chǎn)品,數(shù)據(jù)庫(kù)方面要做優(yōu)化。
我最近開(kāi)始使用p6spy來(lái)做優(yōu)化。
配置參考了:
利用P6SPY +SQL Profiler記錄、統(tǒng)計(jì)web app對(duì)數(shù)據(jù)庫(kù)的操作。
SQL Profiler
report報(bào)表格式為
<%>,<Time(ms)>,<count>,"<Table(s)>","<Column(s)>","<Query prepared if exist or Query SQl>"
其中
<%>:the ratio between outgoing traffic (meaning data from your application to the database)
?versus incoming traffic (from the database to your application)
?負(fù)載平衡
<Time(ms)>:執(zhí)行的時(shí)間
<count>:執(zhí)行次數(shù)
Table(s):表名(包括語(yǔ)句類型)
Column(s):列名
Query prepared if exist or Query SQl:執(zhí)行的SQL 語(yǔ)句
分析報(bào)表按照?qǐng)?zhí)行的時(shí)間(Time)排序,
分析圖 上半部份:
- Queries / second :
包含進(jìn)入數(shù)據(jù)庫(kù)的語(yǔ)句和從數(shù)據(jù)庫(kù)返回的結(jié)果(主要是結(jié)果集)
- Statements / second :?
主要包含進(jìn)入數(shù)據(jù)庫(kù)的語(yǔ)句(包含INSERT, SELECT, DELETE, UPDATE等)
- Results / second :
主要是從數(shù)據(jù)庫(kù)返回并且讓?xiě)?yīng)用讀取的結(jié)果集,它的單位是行。
- SELECT statements / second :
每秒SELECT語(yǔ)句的數(shù)量。在應(yīng)用中的大部分參考數(shù)據(jù)非常拉近于這個(gè)值。
下半部份:
-? Outgoing bytes / second :從應(yīng)用到數(shù)據(jù)庫(kù)的數(shù)據(jù)
-? Incoming bytes / second :從數(shù)據(jù)庫(kù)返回應(yīng)用的數(shù)據(jù)