Parallel Execution: Large/Shared Pool and ORA-4031 (文档 ID 238680.1)

Applies to
Oracle Database - Enterprise Edition - Version 8.1.7.0 and later
Information in this document applies to any platform.

Purpose
Give some information what can be check if we get and ORA-4031 and we use Parallel Execution

Scope
Support Analysts and DBA's

Details
Parallel Execution slave have to exchange data and messages that they can work together.  For this we have to allocate memory from the shared pool or large pool.  This decision depends to which value PARALLEL_AUTOMATIC_TUNING is set.
If  PARALLEL_AUTOMATIC_TUNING = TRUE than we take memory from the large pool otherwise we use the shared pool. In this case we increase automatically the large pool that it should big enough.
The hidden parameter _PX_use_large_pool can also be used to control from which pool we allocate the memory.  At startup of the database we allocate some memory for the "PX msg pool" to avoid fragmentation and get faster memory for the PX buffers, when PARALLEL_AUTOMATIC_TUNING or PARALLEL_MIN_SERVERS is set.


In 10g,  PX message buffers are allocated from  large pool if
a.) parallel_automatic_tuning = true (deprecated)
or
b.) _PX_use_large_pool = true
or
c.) sga_target is set

In 11g,  PX message buffers are allocated from  large pool if
a.) parallel_automatic_tuning = true (deprecated)
or
b.) _PX_use_large_pool = true
or
c.)  SGA memory is auto tuned (sga_target or memory_target)

You can monitor from which area we allocate memory for PX msg buffer when we query V$SGASTAT and look  for the "PX msg pool" The PX message buffer can become very large. Another area in the shared pool where we allocate memory for PX operation is the "PX subheap". This heap is small when we compare it with the "PX msg pool" and always in the shared pool.
select * from v$sgastat;
POOL        NAME                            BYTES
----------- -------------------------- ----------
            fixed_sga                      453632
            log_buffer                     656384
shared pool enqueue                        179220
..
shared pool PX subheap                     167104   <<<<
..
shared pool event statistics per sess     1889720
shared pool fixed allocation callback         184
large pool  PX msg pool                   2949120   <<<<
large pool  free memory                   5439488
java pool   free memory                  25165824
If PARALLEL_AUTOMATIC_TUNING = FALSE the shared pool will not be increased.  The user is responible to find a adequate size for the shared pool.
The size of the PX msg depends also on size of the parameter PARALLEL_EXECUTION_MESSAGE_SIZE and the degree of parallelism.
To obtain more memory usage statistics, execute the following query:
SELECT * FROM V$PX_PROCESS_SYSSTAT WHERE STATISTIC LIKE 'Buffers%';
Your output should resemble the following:
STATISTIC                           VALUE
-------------------                 -----
Buffers Allocated                   23225
Buffers Freed                       23225
Buffers Current                         0
Buffers HWM                          3620
4 Rows selected.
The amount of memory used appears in the Buffers Current and Buffers HWM statistics. Calculate a value in bytes by multiplying the number of buffers by the value for PARALLEL_EXECUTION_MESSAGE_SIZE.
The formula is not 100% correct. To avoid fragmentation of the shared/large pool we allocate in large chunks. This means the value of 'PX msg pool' can be larger than 'Buffers HWM' * PARALLEL_EXECUTION_MESSAGE_SIZE.  
Recommendation
When you receive an ORA-4031 and you have set PARALLEL_AUTOMATIC_TUNING = FALSE then consider to set it to true that Oracle can tune the large pool.
When you have  PARALLEL_AUTOMATIC_TUNING = TRUE than increase the large pool.
In both cases please also check the value of PARALLEL_EXECUTION_MESSAGE_SIZE.

参考至:https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=80dsfjl8t_4&_afrLoop=446004159656844

如有错误,欢迎指正

邮箱:czmcj@163.com

这个错误通常是因为在Windows上使用了错误的入口点(entry point)导致的。在Windows上,C程序的入口点应该是`int main()`而不是`WinMain`。请确保您的代码中有正确的`int main()`函数,并且没有定义`WinMain`函数。 以下是一个简单的示例程序,用于计算n个数字的总和,您可以尝试运行它: ```c #include <stdio.h> #include <omp.h> int main() { int n = 1000000; // 输入要计算总和的数字个数 int* numbers = (int*)malloc(n * sizeof(int)); // 初始化数字数组 for (int i = 0; i < n; i++) { numbers[i] = i + 1; } // 使用OpenMP reduction子句的算法 double start_time = omp_get_wtime(); int sum1 = 0; #pragma omp parallel for reduction(+:sum1) for (int i = 0; i < n; i++) { sum1 += numbers[i]; } double end_time = omp_get_wtime(); printf("使用OpenMP reduction子句的总和: %d\n", sum1); printf("使用OpenMP reduction子句的运行时间: %lf 秒\n", end_time - start_time); // 让每个线程计算部分总和并累加的算法 start_time = omp_get_wtime(); int num_threads = omp_get_max_threads(); int* partial_sums = (int*)malloc(num_threads * sizeof(int)); #pragma omp parallel { int thread_id = omp_get_thread_num(); int num_elements_per_thread = n / num_threads; int start = thread_id * num_elements_per_thread; int end = start + num_elements_per_thread; int partial_sum = 0; for (int i = start; i < end; i++) { partial_sum += numbers[i]; } partial_sums[thread_id] = partial_sum; #pragma omp barrier if (thread_id == 0) { int sum2 = 0; for (int i = 0; i < num_threads; i++) { sum2 += partial_sums[i]; } end_time = omp_get_wtime(); printf("使用每个线程计算部分总和并累加的总和: %d\n", sum2); printf("使用每个线程计算部分总和并累加的运行时间: %lf 秒\n", end_time - start_time); } } free(numbers); free(partial_sums); return 0; } ``` 请确保您的代码中包含了正确的`int main()`函数,并且没有定义`WinMain`函数。如果问题仍然存在,请提供您的代码,我将尽力帮助您解决问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值