【kingsql分享】关于PGA的研究

1.查询PGA缓存命中率(本例为测试库,100%)
SQL> select * from v$pgastat;

NAME                                                                  VALUE UNIT
---------------------------------------------------------------- ---------- ------------
aggregate PGA target parameter                                    314572800 bytes
aggregate PGA auto target                                         220723200 bytes
global memory bound                                                62914560 bytes
total PGA inuse                                                    69308416 bytes
total PGA allocated                                                96744448 bytes
maximum PGA allocated                                             118622208 bytes
total freeable PGA memory                                          16711680 bytes
process count                                                            40
max processes count                                                      51
PGA memory freed back to OS                                       454557696 bytes
total PGA used for auto workareas                                         0 bytes

NAME                                                                  VALUE UNIT
---------------------------------------------------------------- ---------- ------------
maximum PGA used for auto workareas                                 2512896 bytes
total PGA used for manual workareas                                       0 bytes
maximum PGA used for manual workareas                                     0 bytes
over allocation count                                                     0
bytes processed                                                   393541632 bytes
extra bytes read/written                                                  0 bytes
cache hit percentage                                                    100 percent
recompute count (total)                                                1549

19 rows selected.

2.使用V$SQL_WORKAREA_HISTOGRAM视图来计算数据库有多少工作是在最优形式下完成的。
如果一个工作区域最优地完成工作,也就是说完全在PGA内存中进行,那么就会为OPTIMAL_COUNT列中的值加1。
如果经过了一次或多次传递,那么就会在ONEPASS_COUNT或MULTIPASS_COUNT列的值上加1。
SQL> select optimal_count,round(optimal_count*100/total,2) optimal_perc,onepass_count,round(onepass_count*100/total,2) onepass_perc,multipass_count,round(multipass_count*100/total,2) multipass_perc from (select decode(sum(total_executions),0,1,sum(total_executions)) total,sum(OPTIMAL_EXECUTIONS) optimal_count,sum(ONEPASS_EXECUTIONS) onepass_count,sum(MULTIPASSES_EXECUTIONS) multipass_count from v$sql_workarea_histogram where low_optimal_size>(64*1024))
;

OPTIMAL_COUNT OPTIMAL_PERC ONEPASS_COUNT ONEPASS_PERC MULTIPASS_COUNT MULTIPASS_PERC
------------- ------------ ------------- ------------ --------------- --------------
          496          100             0            0               0              0

//使用V$SQL_WORKAREA_HISTOGRAM视图来计算数据库有多少工作是在最优形式下完成的。
如果一个工作区域最优地完成工作,也就是说完全在PGA内存中进行,那么就会为OPTIMAL_COUNT列中的值加1。
如果经过了一次或多次传递,那么就会在ONEPASS_COUNT或MULTIPASS_COUNT列的值上加1。

//一次传递比没有传递要慢,但需要很多次传递的运算,就一定是数据库存在问题的信号,尤其是如果其中包含大的工作区。
如果很有可能会发现,如果数据库不得不进行(即使是很少量包含大工作区--例如大小介于256M到2G之间的)多次传递时,它也会变慢,并且很难高效运行。

3.要想确定数据库中没有任何大工作区运行在多次传递模式下,可以运行下面这个查询
SQL> select low_optimal_size/1024 low,(high_optimal_size+1)/1024 high,optimal_executions,onepass_executions,multipasses_executions from v$sql_workarea_histogram where total_executions!=0;

       LOW       HIGH OPTIMAL_EXECUTIONS ONEPASS_EXECUTIONS MULTIPASSES_EXECUTIONS
---------- ---------- ------------------ ------------------ ----------------------
         2          4              17649                  0                      0
        64        128                 56                  0                      0
       128        256                 18                  0                      0
       256        512                 12                  0                      0
       512       1024                466                  0                      0
      1024       2048                  4                  0                      0
      2048       4096                  6                  0                      0

7 rows selected.

4.还可以运行简单查询来查看V$SYSSTAT和V$SESSTAT等视图,找出到底有多少工作区由数据库在最优内存大小下(在PGA中)、一次传递以及多次传递模式下执行:
select name profile,cnt,decode(total,0,0,round(cnt*100/total)) percentage from (select name,value cnt,(sum(value) over ()) total from v$sysstat where name like 'workarea exec%');

SQL> select name profile,cnt,decode(total,0,0,round(cnt*100/total)) percentage from (select name,value cnt,(sum(value) over ()) total from v$sysstat where name like 'workarea exec%');

PROFILE                                                                 CNT PERCENTAGE
---------------------------------------------------------------- ---------- ----------
workarea executions - optimal                                         18716        100
workarea executions - onepass                                             0          0
workarea executions - multipass                                           0          0

//这个查询显示出了自数据库自动以来,在这三种不同的执行模式(最优、一次传递、多次传递)下所执行的总工作区数。
要想获得一定时间段内的这些信息,可以使用包含ASH(Automatic Session History)的查询。
还可以查看AWR中的内容,从而查看所选定的时间段中数据库的PGA内存使用情况。
如果定期创建这些报告并保存下来,就可以获得在一定时间内PGA内存的分配情况的历史记录。
还可以查看ADDM报告,来衡量在一定的时间段内数据库分别有多少比例的工作运行在前面所述三种模式下。

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
我的QQ 1749160152
我的邮箱 hongzhuohui@kingsql.com
我的百科 http://baike.sogou.com/v82076725.htm?sp=SST洪卓辉
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28389881/viewspace-1268475/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28389881/viewspace-1268475/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值