问题:
在分析AWR报告时,在Instance Efficiency Percentages (Target 100%)中有“Execute to Parse %”统计项,
而且该值一般并不是期望的接近100,一般达到60-70%都认为正常。
本文通过如下方法,帮助进一步理解该参数:
(一)分析STATSPACK中该参数计算方法
(二)执行SQL,跟踪会话统计信息中相关统计项变化
1,计算公式,含义
在相关文档中查到该参数定义如下:
Execute to Parse % = 100% * (1 - Parses/Executions)
该参数是语句执行和分析了多少次的度量。可以这么理解:
* 在一个分析,然后执行语句,且再也不在同一个会话中执行它的系统中,这个比值为0。
* 如果系统Parses > Executions,就可能出现该比率小于0的情况,该值<0通常说明shared pool设置或效率存在问题,造成反复解析。
* 如果该值为负值或者极低,通常说明数据库性能存在问题。
2,分析STATSPACK中该比值计算方法
2.1报表输出项
$ORACLE_HOME/rdbms/admin/sprepins.sql:
select 'Instance Efficiency Indicators' ch30n
,'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' ch30n
,' Buffer Nowait %:' ch28n
, round(100*(1-:bfwt/:gets),2) pctval
,' Redo NoWait %:' ch20
, decode(:rent,0,to_number(null), round(100*(1-:rlsr/:rent),2)) pctval
,' Buffer Hit %:' ch28n
, round(100*(1 - :phyrc/:gets),2) pctval
,' Optimal W/A Exec %:' ch20
, decode((:srtm+:srtd),0,to_number(null),
round(100*:srtm/(:srtd+:srtm),2)) pctval
,' Library Hit %:' ch28n
, round(100*:lhtr,2) pctval
,' Soft Parse %:' ch20
, round(100*(1-:hprs/:prse),2) pctval
,' Execute to Parse %:' ch28n
, round(100*(1-:prse/:exe),2) pctval
,' Latch Hit %:' ch20
, round(100*(1-:lhr),2) pctval
,'Parse CPU to Parse Elapsd %:' ch28n
, decode(:prsela, 0, to_number(null)
, round(100*:prscpu/:prsela,2)) pctval
,' % Non-Parse CPU:' ch20
, decode(:tcpu, 0, to_number(null)
, round(100*(1-(:prscpu/:tcpu)),2)) pctval
from sys.dual;
==>注意其中'Execute to Parse %:' 项:round(100*(1-:prse/:exe),2)
2.2获取prse,exe数值:
$ORACLE_HOME/rdbms/admin/sprepins.sql:
begin
STATSPACK.STAT_CHANGES
(
...
prse,
...
exe,
...
);
...
end;
/
2.3查看STATSPACK.STAT_CHANGES代码:
$ORACLE_HOME/rdbms/admin/spcpkg.sql:
procedure STAT_CHANGES:
begin
...
prse := SYSDIF('parse count (total)');
...
exe := SYSDIF('execute count');
...
end;
==>函数SYSDIF用于获取统计数据之差,即v$sysstat中相关统计项两次snap之间的差值
2.4相关统计项:
select * from v$statname where name in('parse count (total)','execute count');
STATISTIC# NAME CLASS STAT_ID
338 parse count (total) 64 63887964
342 execute count 64 2453370665
SELECT * FROM v$sysstat WHERE statistic# IN (342, 338);
STATISTIC# NAME CLASS VALUE STAT_ID
338 parse count (total) 64 109842769 63887964
342 execute count 64 181337684 2453370665
这里:
parse count (total):解析次数,包括软解析和硬解析
execute:执行次数,包括递归执行
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/18922393/viewspace-696960/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/18922393/viewspace-696960/