1.2 共享池推荐大小:从v$shared_pool_advice中获取,判断条件是,如果shared增加10%,可以减少2%左右的解析时间,取最大的一个点。Sql语句见下表
select max(shared_pool_size_for_estimate) from (select shared_pool_size_for_estimate, nvl((estd_lc_time_saved_factor - lag(estd_lc_time_saved_factor, 1) over(order by shared_pool_size_factor)), estd_lc_time_saved_factor - 1) * 100 as time_save_factor from v$shared_pool_advice where estd_lc_time_saved_factor > 1.005) where time_save_factor > 2
select round((sum(PINS) - sum(RELOADS)) / sum(PINS) * 100,2) Hit_Ratio from v$librarycache
select round(sum(decode(executions,1,0,1))/count(1)*100,2) from v$sqlarea
1.6 数据缓存推荐大小:从v$db_cache_advice获取的DEFAULT cache的建议值。如果数据库参数db_cache_advice是OFF,则该字段显示为OFF,否则判断条件为,如果buffer cache每增加10%的大小,可以减少25%的物理读时间,则进入候选队列,取候选队列中的最大值。Sql语句如下
select max(size_for_estimate) from (select size_for_estimate, nvl((lag(estd_physical_read_factor, 1) over(order by size_factor) -estd_physical_read_factor ), 0) * 10 as time_save_factor from v$db_cache_advice where estd_physical_read_factor <= 1 and name = 'DEFAULT') where time_save_factor > 0.5
select round(((consistent_gets + db_block_gets) - physical_reads) / (consistent_gets + db_block_gets) * 100,2) "Hit Ratio%" from v\$buffer_pool_statistics where physical_reads > 0 and name = 'DEFAULT'
1.9 PGA推荐大小:从v$pga_target_advice视图中获取。重点讲这个视图的estd_pga_cache_hit_percentage是评估的pga命中率,计算公式BYTES_PROCESSED / (BYTES_PROCESSED + ESTD_EXTRA_BYTES_RW),这个值越大越好。ESTD_OVERALLOC_COUNT字段的值应该为0,如果不为0,说明PGA不足。
select min(pga_target_for_estimate / 1024 / 1024) from v$pga_target_advice where ( estd_pga_cache_hit_percentage, estd_overalloc_count) in (select max(estd_pga_cache_hit_percentage), min(estd_overalloc_count) from v$pga_target_advice)
SELECT ROUND(optimal_count / total_count * 100, 2) "optimal_pct", ROUND(onepass_count / total_count * 100, 2) "onepass_pct", ROUND(multipass_count / total_count * 100, 2) "multipass_pct" FROM (SELECT SUM(a.total_executions) total_count, SUM(a.optimal_executions) optimal_count, SUM(a.onepass_executions) onepass_count, SUM(a.multipasses_executions) multipass_count FROM v\$sql_workarea_histogram a WHERE a.total_executions <> 0)
1.12 m-pass比例: 使用multi-pass mode完成排序的比例。具体解析见1.10。
共享池推荐大小 | Library命中率 | 执行次数大于1的SQL占比 | 数据缓存推荐大小 | Buffer命中率 | PGA推荐大小 | optimal比例 |
---|---|---|---|---|---|---|
有值 | <99 | <70 | 有值 | <80 | 有值 | <95 |
1.2 执行次数大于1的SQL占比低于阀值:系列主管DBA应推动开发使用绑定变量。
1.3 m-pass值过高: 系列主管DBA应根据数据库的业务类型判断是否合理,是否存在sql过量使用排序(不合理的hash join)。