Home  >  Article  >  Database  >  Oracle中PGA内存分配原则

Oracle中PGA内存分配原则

WBOY
WBOYOriginal
2016-06-07 17:33:18972browse

Oracle在评估执行计划时会更具PGA_AGGREGATE_TARGET参数评估在sort,HASH_JOIN或Bitmap操作时能够使用的最大或最小内存,从而选择

pga_aggregate_target 通常缩写为P_A_T,该参数同时限制全局pga分配和私有工作区内存分配

在Oracle9i以及10gr1中,单个sql操作内存使用存在如下限制:

对于串行操作,单个sql操作能够使用的pga内存按照一下原则分配:

MIN(5%*PGA_AGGREGATE_TARGET,100MB)

此处的5%*PGA_AGGREGATE_TARGET实际上是由_smm_nax_size决定的,该参数限制自动工作区模式下最大的工作区使用

对于并行操作:

30%PGA_AGGREGATE_TARGET/DOP(DOP=DEGREE IF PARALLELISM,并行度)

在oracle10gr2以及oracle11g中,内存使用存在如下限制:

对于串行操作,能够使用的pga内存按照以下原则分配:

如果P_A_T

如果P_A_T在500MB和1000MB之间,_smm_max_size=100MB

如果P_A_T介于1001MB和2560MB之间,_smm_max_size=10%*P_A_T

如果P_A_T>2560MB则_smm_max_size=262060MB

对于并行操作,能够使用的pga内存按照以下原则分配:

50%PGA_AGGREGATE_TARGET/DOP (DOP=Degree of parallelism,并行度)

但是注意,当dop

从oralce10g开始 pga算法受一个新增的隐含参数_newsort_abled影响,如果将该参数设置为false,,则数据库会使用之前oracle9i中的算法规则:

sys@ORCL>@gethidpar.sql

输入 name 的值:  newsort_enabled

原值    4: and x.ksppinm like'%&name%'

新值    4: and x.ksppinm like'%newsort_enabled%'

KSPPINM          KSPPSTVL

_newsort_enabled          TRUE

上述@gethidpar.sql内容:

select x.ksppinm,y.ksppstvl,x.ksppdesc from x$ksppi x,x$ksppcv y wherex.indx=y.indx

and y.inst_id=userenv('Instance')

and x.inst_id=userenv('Instance')

and x.ksppinm like '%&name%';

要理解pga的自动调整,还需要区分可调整内存(TUNABLE MEMORY SIZE) 与不可调整内存(UNTUNABLE MEMORY SIZE),可调整内存是由sql工作区使用的,其余部分是不可调整内存

Oracle在评估执行计划时会更具PGA_AGGREGATE_TARGET参数评估在sort,HASH_JOIN或Bitmap操作时能够使用的最大或最小内存,从而选择最优的执行计划

对于一个单纯的数据库服务器,通常我们需要保存20%的物理内存给操作系统使用,剩余80%可以分配给oracle使用,而oracle的内存由pga和sga构成,pga可以占用oracle消耗内存的20%(OLTP系统)至50%(DSS系统)

通过v$process 可以查询pga的相关使用情况:

V$PROCESS displays information about the currently active processes.

Column

Datatype

Description

ADDR

RAW(4 | 8)

Address of the process state object

PID

NUMBER

Oracle process identifier

SPID

VARCHAR2(24)

Operating system process identifier

PNAME

VARCHAR2(5)

Name of this process

USERNAME

VARCHAR2(15)

Operating system process username

Note: Any two-task user coming across the network has "-T" appended to the username.

SERIAL#

NUMBER

Process serial number

TERMINAL

VARCHAR2(30)

Operating system terminal identifier

PROGRAM

VARCHAR2(48)

Program in progress

TRACEID

VARCHAR2(255)

Trace file identifier

TRACEFILE

VARCHAR2(513)

Trace file name of the process

BACKGROUND

VARCHAR2(1)

1 for a background process; NULL for a normal process

LATCHWAIT

VARCHAR2(8)

Address of the latch the process is waiting for; NULL if none

LATCHSPIN

VARCHAR2(8)

This column is obsolete

PGA_USED_MEM

NUMBER

PGA memory currently used by the process

PGA_ALLOC_MEM

NUMBER

PGA memory currently allocated by the process (including free PGA memory not yet released to the operating system by the server process)

PGA_FREEABLE_MEM

NUMBER

Allocated PGA memory which can be freed

PGA_MAX_MEM

NUMBER

Maximum PGA memory ever allocated by the process

更多详情见请继续阅读下一页的精彩内容:

相关阅读:

修改Oracle数据库SGA和PGA大小

Oracle内存结构研究-PGA篇 

Oracle在专用与共享的模式下SGA和PGA的区别 

Oracle 内存管理PGA 

Oracle内存全面分析之PGA 

Oracle的内存分配-内存分配(SGA和PGA)SGA和PGA结构图

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn