我下面给出一个具体的示例: alter system set "_pga_max_size"=10m scope=both; alter system set pga_aggregate_target=100m scope=both; SQL> shutdown immediate startup SQL> select ksppinm as "hidden parameter", ksppstvl as "value" from x$ksppi join x$ksppcv using (indx) where ksppinm like "%_pga_max_size%" order by ksppinm; hidden parameter -------------------------------------------------------------------------------- value -------------------------------------------------------------------------------- _pga_max_size 10485760 <=========限制单个进程使用PGA 100M(其实是work area)
执行一个PL/SQL,使用bulk collect使其内存使用大大超过pga_aggregate_target和_pga_max_size: DECLARE CURSOR c1 IS SELECT * FROM Oracle.employees; TYPE emp_row IS TABLE OF c1%ROWTYPE; table_set emp_row; BEGIN -- Assign values to nested table of records: SELECT * BULK COLLECT INTO table_set FROM oracle.employees; -- Print nested table of records:
FOR i IN table_set.FIRST .. table_set.LAST LOOP DBMS_OUTPUT.PUT_LINE ( table_set(i).email || " " || table_set(i).last_name || ", " || table_set(i).first_name ); END LOOP;END; /
select pid,spid,program,pga_used_mem/1024/1024,pga_alloc_mem/1024/1024 from v$process where spid=3735758
select a.name,to_char(b.value,"999,999,999") value from v$statname a,v$mystat b where a.statistic# = b.statistic# and a.name like "%ga memory%";
NAME VALUE ---------------------------------------------------------------- ------------ session uga memory 1,896,024 session uga memory max 1,896,024 session pga memory 2,330,120 session pga memory max 647,400,968 <==========Peak PGA size for the session. 647,400,968
12c新追加了一个参数PGA_AGGREGATE_LIMIT来限制PGA的大小: Limiting process size with database parameter PGA_AGGREGATE_LIMIT (Doc ID 1520324.1) 更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12本文永久更新链接地址