技术开发 频道

PGA自动管理原理深入分析及性能调整

【IT168技术文档】

3.5 PGA的自动建议特性
那么,如果我们需要调整pga_aggregate_target时,到底我们应该设置多大呢?oracle为了帮助我们确定这个参数的值,引入了一个新的视图:v$pga_target_advice。为了使用该视图,需要将初始化参数statistics_level设置为typical(缺省值)或all。
SQL> select
  2     round(pga_target_for_estimate /(1024*1024)) "Target (M)",
  3     estd_pga_cache_hit_percentage "Est. Cache Hit %",
  4     round(estd_extra_bytes_rw/(1024*1024)) "Est. ReadWrite (M)",
  5     estd_overalloc_count "Est. Over-Alloc"
  6    from v$pga_target_advice
  7  /

Target (M) Est. Cache Hit % Est. ReadWrite (M) Est. Over-Alloc
---------- ---------------- ------------------ ---------------
        15               34                264               1
        30               34                264               0
        45               34                264               0
        60               67                 66               0
        72               67                 66               0
        84               67                 66               0
        96               67                 66               0
       108               67                 66               0
       120               67                 66               0
       180               67                 66               0
       240               67                 66               0
       360               67                 66               0
       480               67                 66               0
该输出告诉我们,按照系统目前的运转情况,我们pga设置的不同值所带来的不同效果。根据该输出,我们找到能使estd_overalloc_count为0的最小pga_aggregate_target的值。从这里可以看出,是30M。注意,随着我们增加pga的尺寸,estd_pga_cache_hit_percentage不断增加,同时estd_extra_bytes_rw(表示onepass、multipass读写的字节数)不断减小。从上面的结果,我们可以知道,将pga_aggregate_target设置为60MB是最合理的,因为即便将其设置为480MB,命中率也不会有所提高。

同时,我们知道v$tempstat里记录了读写临时表空间的数据块数量以及所花费的时间。这样,我们就可以结合v$pga_target_advice和v$tempstat这两个视图。可以得到每一种估计PGA值下的响应时间大致是多少,从而可以换一个角度来显示PGA的建议值:
SQL> SELECT 'PGA Aggregate Target' component,
  2   ROUND (pga_target_for_estimate / 1048576) target_size,
  3   estd_pga_cache_hit_percentage cache_hit_ratio,
  4   ROUND ( ( ( estd_extra_bytes_rw / DECODE ((b.BLOCKSIZE * i.avg_blocks_per_io),0, 1,
  5     (b.BLOCKSIZE * i.avg_blocks_per_io)))* i.iotime)/100 ) "response_time(sec)"
  6  FROM v$pga_target_advice,
  7  (SELECT /*+AVG TIME TO DO AN IO TO TEMP TABLESPACE*/
  8   AVG ( (readtim + writetim) /
  9    DECODE ((phyrds + phywrts), 0, 1, (phyrds + phywrts)) ) iotime,
 10   AVG ( (phyblkrd + phyblkwrt)/
 11    DECODE ((phyrds + phywrts), 0, 1, (phyrds + phywrts))) avg_blocks_per_io
 12  FROM v$tempstat) i,
 13  (SELECT /* temp ts block size */ VALUE BLOCKSIZE
 14   FROM v$parameter WHERE NAME = 'db_block_size') b;
COMPONENT            TARGET_SIZE CACHE_HIT_RATIO response_time(sec)
-------------------- ----------- --------------- ------------------
PGA Aggregate Target          15              34                 85
PGA Aggregate Target          30              34                 85
PGA Aggregate Target          45              34                 85
PGA Aggregate Target          60              68                 21
PGA Aggregate Target          72              68                 21
PGA Aggregate Target          84              68                 21
PGA Aggregate Target          96              68                 21
PGA Aggregate Target         108              68                 21
PGA Aggregate Target         120              68                 21
PGA Aggregate Target         180              68                 21
PGA Aggregate Target         240              68                 21
PGA Aggregate Target         360              68                 21
PGA Aggregate Target         480              68                 21
注意,每次我们调整了pga_aggregate_target参数以后,都应该在系统运行一、两天以后检查视图:v$sysstat、v$pgastat、v$pga_target_advice,以确定修改的值是否满足系统的需要。
 

0
相关文章