重慶思莊oracle技術(shù)分享-pga相關(guān)參數(shù)
PGA
? ??UGA:session信息,WORK AREA(hash area,sort area等)等等
? ??CGA:parse調(diào)用、executive調(diào)用、fetch調(diào)用等
pga_aggregate_target設(shè)定所有進(jìn)程總的WORK AREA區(qū)大小,主要影響下面幾個(gè)相關(guān)參數(shù)的設(shè)定
? ??_smm_max_size: 串行進(jìn)程的WORK AREA上限值,單位KB。默認(rèn)值
? ??_pga_max_size: 每個(gè)進(jìn)程WORK AREA上限值,單位byte。
? ??_smm_px_max_size: 并行模式下,所有并行進(jìn)程共享的WORK AREA上限值,單位KB
_smm_max_size:
? ? pga_aggregate_target??<= 500 MB, then _smm_max_size = 20% * pga_aggregate_target
? ? pga_aggregate_target??[500MB , 1000 MB], then _smm_max_size = 100 MB
? ? pga_aggregate_target??>= 1000 MB, then _smm_max_size = 10% * pga_aggregate_target, 最大值 1024MB
_pga_max_size:
? ? _smm_max_size <= 100m,then _pga_max_size=200m
? ? _smm_max_size > 100m,then _pga_max_size = 2 * _smm_max_size
_smm_px_max_size:
? ? _smm_px_max_size = 50% * pga_aggregate_target
? ? degree of parallelism (DOP) <= 5, 每個(gè)slave進(jìn)程使用_smm_max_size限制
? ? degree of parallelism (DOP) > 5,??所有slave進(jìn)程共享_smm_px_max_size
從上面的分析,我們可以得到下面的一些指導(dǎo):
1、增大pga_aggregate_target設(shè)置,可以提高每個(gè)進(jìn)程的work area大小,對(duì)于hash join、排序等操作有利
2、PGA達(dá)到10G后,單個(gè)進(jìn)程的work area已經(jīng)達(dá)到極限,不能再獲得更大的空間了
3、在CPU足夠的情況,設(shè)置并行度超過(guò)6,可以獲得更大的work area空間,比如創(chuàng)建索引就會(huì)更快
4、如果大量進(jìn)程啟用高并行度,操作系統(tǒng)內(nèi)存很容易被消耗光,因?yàn)镻GA只是限定了work area的空間,而其他的組件可以越界。
綜上,pga_aggregate_target并不是硬性限制,work area之外的內(nèi)存,不被pga_aggregate_target和_pga_max_size所限制。所以經(jīng)常會(huì)看到PGA的大小超過(guò)了pga_aggregate_target,這通常是因?yàn)镻L/SQL中的變量和數(shù)組中裝入了巨大的數(shù)據(jù)造成的。通常的例子是bulk collect。
在12c中引入了PGA_AGGREGATE_LIMIT參數(shù),可用來(lái)硬性限制PGA大小。
In Oracle release 12.1:??the greater of the following:
* 2 GB
* 200% of PGA_AGGREGATE_TARGET
* (Value of PROCESSES initialization parameter setting) * 3 MB
It will not exceed 120% of the physical memory size minus the total SGA size.
In Oracle release 12.2:
* If MEMORY_TARGET is set, then PGA_AGGREGATE_LIMIT defaults to the MEMORY_MAX_TARGET value.
* If MEMORY_TARGET is not set, then PGA_AGGREGATE_LIMIT defaults to 200% of PGA_AGGREGATE_TARGET.
* If MEMORY_TARGET is not set, and PGA_AGGREGATE_TARGET is explicitly set to 0, then the value of PGA_AGGREGATE_LIMIT is set to 90% of the physical memory size minus the total SGA size.
In all cases, the default PGA_AGGREGATE_LIMIT is at least 2GB and at least 3MB times the PROCESSES parameter.