一、PGA
PROCESS GLOBAL AREA =====>私有的空间(专用)server process
PGA is part of prcess private memory. heap information can be seen in x$ksmpp
SQL WORK AREA=====> Sort Area, Hash Area, Bigmap, merger Area
PRIVATE SQL AREA===>Session Memory,Persistent Area,Runtime Area
Fixed UGA
Variable UGA(private sql /plsql area, 句柄 open cursors and links,endabled roles and events, and so on)
open cursors and links:每个会话放了指向在共享池中的sql,执行计划的地址(指针);
二、管理PGA 总体来说一般使用自动管理。(9i以上使用自动内存管理)
工作区;
自动管理:
workarea_size_policy string AUTO
实验:
1.准备两个表:
SQL> create table caoyf_t1 as select * from all_objects;
Table created.
SQL> create table caoyf_t2 as select * from all_objects;
Table created.
SQL> select count(*) from caoyf_t1;
COUNT(*)
----------
75131
2.查看当前会话:
SQL> select sid from v$mystat where rownum=1;
SID
----------
125
3 在什么都没有操作的情况下:
SQL> select sid,paddr,PGA_USED_MEM/1024/1024,PGA_ALLOC_MEM,PGA_MAX_MEM from v$session s,v$process p where s.sid=125 and s.paddr = p.addr;
SID PADDR PGA_USED_MEM/1024/1024 PGA_ALLOC_MEM PGA_MAX_MEM
---------- ---------------- ---------------------- ------------- -----------
125 00000000BB4FA8F0 2.51234436 5400392 19442152
2.5M是非工作区(连接所占用的内存) linux一般的连接时2-5M
手动管理
workarea_size_policy string manual;
SQL> show parameter pga
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target big integer 101M 参数就没有作用了。
4.执行排序:
125 00000000BB4FA8F0 2.51234436 5400392 19442152
SQL> SELECT * FROM caoyf_t1,caoyf_t2 order by 1,2,3 ;
SQL> select sid,paddr,PGA_USED_MEM/1024/1024,PGA_ALLOC_MEM,PGA_MAX_MEM from v$session s,v$process p where s.sid=125 and s.paddr = p.addr;
SID PADDR PGA_USED_MEM/1024/1024 PGA_ALLOC_MEM PGA_MAX_MEM
---------- ---------------- ---------------------- ------------- -----------
SQL> select sid,paddr,PGA_USED_MEM/1024/1024,PGA_ALLOC_MEM,PGA_MAX_MEM from v$session s,v$process p where s.sid=125 and s.paddr = p.addr;
SID PADDR PGA_USED_MEM/1024/1024 PGA_ALLOC_MEM PGA_MAX_MEM
---------- ---------------- ---------------------- ------------- -----------
125 00000000BB4FA8F0 91.8235092 121071432 121071432
分
SQL> select sid,paddr,PGA_USED_MEM/1024/1024,PGA_ALLOC_MEM,PGA_MAX_MEM from v$session s,v$process p where s.sid=125 and s.paddr = p.addr;
SID PADDR PGA_USED_MEM/1024/1024 PGA_ALLOC_MEM PGA_MAX_MEM
---------- ---------------- ---------------------- ------------- -----------
125 00000000BB4FA8F0 95.5553055 121071432 121071432
我这边是设置为105M ,但是最大使用了113
有两个隐含参数:
_pga_max_size
_smm_max_size
可以修改最大限制