PGA自動管理原理深入分析及效能調整(六)

hanson發表於2019-05-27

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_count0的最小pga_aggregate_target的值。從這裡可以看出,是30M。注意,隨著我們增加pga的尺寸,estd_pga_cache_hit_percentage不斷增加,同時estd_extra_bytes_rw(表示onepassmultipass讀寫的位元組數)不斷減小。從上面的結果,我們可以知道,將pga_aggregate_target設定為60MB是最合理的,因為即便將其設定為480MB,命中率也不會有所提高。

同時,我們知道v$tempstat裡記錄了讀寫臨時表空間的資料塊數量以及所花費的時間。這樣,我們就可以結合v$pga_target_advicev$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$sysstatv$pgastatv$pga_target_advice,以確定修改的值是否滿足系統的需要。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9842/viewspace-410385/,如需轉載,請註明出處,否則將追究法律責任。

相關文章