oracle加并行变慢,并行设置不当导致数据处理速度变慢
問題描述
系統遷移,由單節點4cpu服務器遷移到雙節點rac,32顆cpu系統中,遷移后對特定數據新服務器的處理速度反而不如老服務器。
問題分析
出現兩側代碼相同但執行結果相差很大的原因是表SAVE_POINT_CACHE并行度的設置
表SAVE_POINT_CACHE中數據非常少,只有幾十條
在系統中表SAVE_POINT_CACHE的并行度設置為default
根據oracle對并行度的算法
Default = parallel_threads_per_cpu * cpu_count
我們系統中兩邊的設置都是如下的情況
NAMETYPEVALUE
------------------------------------ ----------- ------------------------------
parallel_threads_per_cpuinteger2
也就是每個cpu的并行度為2
老系統中系統共有4顆cpu
prtdiag -v結果片段
========================= CPUs
RunE$CPUCPU
BrdCPUMHzMB Impl.Mask
--- ----- ---- ---- ------- ----
A0, 16 1500 32.0 US-IV+2.4
B1, 17 1500 32.0 US-IV+2.4
A2, 18 1500 32.0 US-IV+2.4
B3, 19 1500 32.0 US-IV+2.4
并行度的結果就是4*2=8
Rac新系統中每個服務器有32顆cpu,
并行度的結果就是2*32=64
在并行度設置為default情況下測試代碼結果如下:
老系統時間為26.89秒
SQL> set timing on
SQL> BEGIN
2insert into save_point_cache values('dummytask_a',sysdate, 1);
3insert into save_point_cache values('begin_a',sysdate, 1);
4commit;
5
6FOR lc IN 1 .. 1000
7LOOP
8SAVE_POINT.SAVE_TASK ( 'dummytask_a', sysdate, lc );
9COMMIT;
10END LOOP;
11
12insert into save_point_cache values('end_a',sysdate, 1);
13commit;
14END;
15/
PL/SQL procedure successfully completed.
Elapsed: 00:00:26.89
Rac新系統時間為4:32.17
SQL> set timing on
SQL> BEGIN
2insert into save_point_cache values('dummytask_a',sysdate, 1);
3insert into save_point_cache values('begin_a',sysdate, 1);
4commit;
5
6FOR lc IN 1 .. 1000
7LOOP
8SAVE_POINT.SAVE_TASK ( 'dummytask_a', sysdate, lc );
9COMMIT;
10END LOOP;
11
12insert into save_point_cache values('end_a',sysdate, 1);
13commit;
14END;
15/
PL/SQL procedure successfully completed.
Elapsed: 00:04:32.17
并且在代碼運行期間主要的等待事件為
PX Deq Credit: send blkd
PX Deq: reap credit
對于這兩個等待事件,oracle的解釋如下:
PX Deq: reap credit
Waiting Process: Slave
This wait event indicates that we are doing a non-blocking test to see if any channel has returned a message. We should see that although there is a high number of these events, the time accumulated to it should be zero (or really low).
Tips to Reduce Waits for "PX DEQ CREDIT SEND BLKD" at Database Level
The wait events"PX Deq Credit: need buffer"and"PX Deq Credit: send blkd" are occur when data ormessages are exchanged between process that are part of a px query..
There are at least 3 different main area's that can cause this waits.
We see high waits if a lot of data and message are exchanged between parallel processes. The cause can be that the execution plan is bad or there are problem with the parallel execution setup.
There is a problem with the resource like the CPU or the interconnect. As example with a CPU utilization around 100% the process are limited by the CPU and can not send the data fast enough.
If parallel queries are hang where one process waits for "PX Deq Credit: need buffer" as example.
出現問題的主要原因是并行處理sql過程中cpu之間數據交換等待導致處理速度變慢
處理方法:
關閉表save_point_cache的并行
在兩邊同時關閉表的并行重新測試
SQL> alter table save_point_cache noparallel;
Table altered.
98老系統用時1.60秒
SQL> set timing on
SQL> BEGIN
2insert into save_point_cache values('dummytask_a',sysdate, 1);
3insert into save_point_cache values('begin_a',sysdate, 1);
4commit;
5
6FOR lc IN 1 .. 1000
7LOOP
8SAVE_POINT.SAVE_TASK ( 'dummytask_a', sysdate, lc );
9COMMIT;
10END LOOP;
11
12insert into save_point_cache values('end_a',sysdate, 1);
13commit;
14END;
15/
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.60
Rac新系統用時1.14秒
SQL> set timing on
SQL> BEGIN
2insert into save_point_cache values('dummytask_a',sysdate, 1);
3insert into save_point_cache values('begin_a',sysdate, 1);
4commit;
5
6FOR lc IN 1 .. 1000
7LOOP
8SAVE_POINT.SAVE_TASK ( 'dummytask_a', sysdate, lc );
9COMMIT;
10END LOOP;
11
12insert into save_point_cache values('end_a',sysdate, 1);
13commit;
14END;
15/
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.14
速度都非常理想
總結
以上是生活随笔為你收集整理的oracle加并行变慢,并行设置不当导致数据处理速度变慢的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 行转列 oracle nvl,oracl
- 下一篇: oracle修改删除数据,[Oracle