看到很多讲述sga性能检查和调整的文章但pga的检查和调整的很少,今天将自己看到并测试过的pga的性能检查的方式列一下。
以下方法来自《oracle10g 数据库管理艺术》
检查pga
查询v$pga_target_advice视图的估算,参考设置最佳水平PGA值。
select round(pga_target_for_estimate/1024/1024) target_mb,
estd_pga_cache_hit_percentage cache_hit_perc,
estd_overalloc_count
4 from v$pga_target_advice;
TARGET_MB CACHE_HIT_PERC ESTD_OVERALLOC_COUNT
---------- -------------- --------------------
224 97 2
448 97 0
895 98 0
1343 98 0
1790 98 0
2148 98 0
2506 98 0
2864 98 0
3222 98 0
3580 98 0
5370 98 0
TARGET_MB CACHE_HIT_PERC ESTD_OVERALLOC_COUNT
---------- -------------- --------------------
7160 98 0
10740 98 0
14320 98 0
14 rows selected.
查看v$pgastat视图获得当前PGA状态
SQL> set linesize 200;
SQL> select * from v$pgastat;
NAME VALUE UNIT
---------------------------------------------------------------- ---------- ------------
aggregate PGA target parameter 1876951040 bytes
aggregate PGA auto target 1630374912 bytes
global memory bound 187688960 bytes
total PGA inuse 65419264 bytes
total PGA allocated 167726080 bytes
maximum PGA allocated 1156052992 bytes
total freeable PGA memory 57671680 bytes
process count 66
max processes count 92
PGA memory freed back to OS 6.8473E+12 bytes
total PGA used for auto workareas 0 bytes
NAME VALUE UNIT
---------------------------------------------------------------- ---------- ------------
maximum PGA used for auto workareas 776727552 bytes
total PGA used for manual workareas 0 bytes
maximum PGA used for manual workareas 531456 bytes
over allocation count 0
bytes processed 7.0134E+12 bytes
extra bytes read/written 3.1081E+11 bytes
cache hit percentage 95.75 percent
recompute count (total) 2572343
19 rows selected.
看到一点cache hit percentage (内存的命中率),以上查得为95.75%,命中率在90%以上比较好了。
执行排序的理想方法是在内存中完成整个作业,oracle完全在内存执行的排序作业称为最佳排序(optimal sort)。如果pag_aggregate_target过低,某些排序将直接写在磁盘上(临时表空间),
因为排序太大,内存放不下。如果有部分排序作业溢出到硬盘,称为1遍排序(1-pass sort)。如果实例在磁盘上而不是内存中执行大多数排序工作,则响应时间将很长。
使用v$sql_workarea_histogram视图查看
SQL>
select
low_optimal_size/1024 "Low (K)",
(high_optimal_size+1)/1024 "High (K)",
optimal_executions "Optimal",
onepass_executions "1-Pass",
multipasses_executions ">1 Pass"
from v$sql_workarea_histogram
8 where total_executions <>0;
Low (K) High (K) Optimal 1-Pass >1 Pass
---------- ---------- ---------- ---------- ----------
2 4 266825503 0 0
64 128 955257 0 0
128 256 3509083 0 0
256 512 281736 0 0
512 1024 632480 0 0
1024 2048 54281 0 0
2048 4096 205148 9 0
4096 8192 1634 181 0
8192 16384 1900 147 0
16384 32768 210495 257 0
32768 65536 530 34 0
Low (K) High (K) Optimal 1-Pass >1 Pass
---------- ---------- ---------- ---------- ----------
65536 131072 1258 44 0
131072 262144 53 40 0
262144 524288 0 756 0
524288 1048576 0 17 0
1048576 2097152 0 10 0
2097152 4194304 0 1 0
17 rows selected.
v$process_memory视图允许查看每个oracle进程的动态PGA内存使用情况,并按照类别显示PGA使用情况。
SQL> select pid,category,allocated,used from v$process_memory;
PID CATEGORY ALLOCATED USED
---- --------------- ---------- ----------
2 PL/SQL 2088 224
2 Other 448477
3 PL/SQL 2088 224
3 Other 448477
4 PL/SQL 2088 224
4 Other 448477
5 PL/SQL 2088 224
5 Freeable 7798784 0
5 Other 1086621
6 PL/SQL 2088 224
6 Freeable 7208960 0
SQL> select PROGRAM,pga_used_mem,
2 pga_alloc_mem,pga_freeable_mem,pga_max_mem from v$process;
PROGRAM PGA_USED_MEM PGA_ALLOC_MEM PGA_FREEABLE_MEM PGA_MAX_MEM
------------------------------------------------ ------------ ------------- ---------------- -----------
PSEUDO 0 0 0 0
oracle@zj-ctpay-db (PMON) 303541 450565 0 450565
oracle@zj-ctpay-db (PSP0) 302509 450565 0 450565
oracle@zj-ctpay-db (MMAN) 307309 450565 0 450565
oracle@zj-ctpay-db (DBW0) 532677 8887493 7798784 16686277
oracle@zj-ctpay-db (DBW1) 645237 8558477 7208960 15767437
oracle@zj-ctpay-db (LGWR) 10864805 24025677 917504 24943181
oracle@zj-ctpay-db (CKPT) 421069 2595749 1966080 4561829
oracle@zj-ctpay-db (SMON) 575277 2334053 1507328 2465125
oracle@zj-ctpay-db (RECO) 443509 974853 327680 974853
oracle@zj-ctpay-db (CJQ0) 695989 5758981 4784128 5824517
以下语句来快速估计自启动oracle实例以来,使用最佳、1遍、多遍PGA内存尺寸的工作区比例:
SQL>
select name profile,cnt COUNT,
decode(total,0,0,round(cnt*100/total)) PERCENTAGE
from (select name,value cnt,(sum(value) over()) total
from v$sysstat
5 where name like 'workarea exec%');
PROFILE COUNT PERCENTAGE
---------------------------------------------------------------- ---------- ---------- ---------- ----------
workarea executions - optimal 272768388 100
workarea executions - onepass 1496 0
workarea executions - multipass 0 0
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/20575781/viewspace-717504/
,如需转载,请注明出处,否则将追究法律责任。