[bbk2193] 第34集 - Chapter 09-Optimizing Sore Perations(03)
PGA Target Advice Statistics
- V$PGA_TARGET_ADVICE predicts how cache hit percentages shown in V$PGASTAT evolve.
- STATISTICS_LEVEL must be set to at least TYPICAL.(提示:如果想使V$PGA_TARGET_ADVICE工作,必须将STATISTIC_LEVEL修改成至少TYPICAL级别)
SQL> select * from v$PGA_TARGET_ADVICE; PGA_TARGET_FOR_ESTIMATE PGA_TARGET_FACTOR ADV BYTES_PROCESSED ESTD_TIME ESTD_EXTRA_BYTES_RW ESTD_PGA_CACHE_HIT_PERCENTAGE ESTD_OVERALLOC_COUNT ----------------------- ----------------- --- --------------- ---------- ------------------- ----------------------------- -------------------- 163577856 .125 ON 6551463936 25831789 72195072 99 6 327155712 .25 ON 6551463936 25550234 0 100 0 654311424 .5 ON 6551463936 25550234 0 100 0 981467136 .75 ON 6551463936 25550234 0 100 0 1308622848 1 ON 6551463936 25550234 0 100 0 1570347008 1.2 ON 6551463936 25550234 0 100 0 1832071168 1.4 ON 6551463936 25550234 0 100 0 2093796352 1.6 ON 6551463936 25550234 0 100 0 2355520512 1.8 ON 6551463936 25550234 0 100 0 2617245696 2 ON 6551463936 25550234 0 100 0 3925868544 3 ON 6551463936 25550234 0 100 0 PGA_TARGET_FOR_ESTIMATE PGA_TARGET_FACTOR ADV BYTES_PROCESSED ESTD_TIME ESTD_EXTRA_BYTES_RW ESTD_PGA_CACHE_HIT_PERCENTAGE ESTD_OVERALLOC_COUNT ----------------------- ----------------- --- --------------- ---------- ------------------- ----------------------------- -------------------- 5234491392 4 ON 6551463936 25550234 0 100 0 7851737088 6 ON 6551463936 25550234 0 100 0 1.0469E+10 8 ON 6551463936 25550234 0 100 0 14 rows selected.
将上述SQL语句,进行优化一下,如下:
SELECT ROUND(pga_target_for_estimate/1024/1024) AS target_mb, estd_pga_cache_hit_percentage AS cach_hit_percent, estd_overalloc_count FROM v$pga_target_advice ORDER BY target_mb; TARGET_MB CACH_HIT_PERCENT ESTD_OVERALLOC_COUNT ---------- ---------------- -------------------- 156 99 6 312 100 0 624 100 0 936 100 0 1248 100 0 1498 100 0 1747 100 0 1997 100 0 2246 100 0 2496 100 0 3744 100 0 TARGET_MB CACH_HIT_PERCENT ESTD_OVERALLOC_COUNT ---------- ---------------- -------------------- 4992 100 0 7488 100 0 9984 100 0 14 rows selected.
解读优化后的SQL语句:以第一条记录为例:假如将PGA_AGGRGATE_TARGET参数值设置为156MB的话,缓存命中率为99%,溢出6块.以下记录依次类推.
Understanding the view
Limitation of Base Statistics
How to Tune
v$sysstat and v$sesstat
SQL> SELECT name profile,cnt,decode(total,0,0,round(cnt*100/total)) percentage 2 FROM (SELECT name,value cnt,(sum(value) over()) total 3 FROM V$SYSSTAT 4 WHERE name like 'workarea exec%' 5 ); PROFILE CNT PERCENTAGE ---------------------------------------------------------------- ---------- ---------- workarea executions - optimal 180593 100 workarea executions - onepass 4 0 workarea executions - multipass 0 0