I am having quite a large volume of data in my Oracle table. Through Oracle Pro*C code, I am trying to use host arrays for managing merge into DB table as per following example:
merge into TBL_NM A
using (select 1 from dual) B
on (col1 = to_date(:v,'YYMMDD') and col2 = :v and col3 = :v and col4 = :v)
when matched then
update set col5 = :v, col2 = col2+ :v, col3 = col3 + :v
when not matched then
insert (col1, col2, col3, col4, col5, col6, col7, col8)
values (to_date(:v,'YYMMDD'),:v,:v,:v,:v,:v,:v,:v)
However, I am experiencing degrading performance when volume increase. It's taking too long a time and I need to optimize the merge for performance.
Will it be any better to use the Parallel DML as well as APPEND hint with the MERGE (upsert) SQL? I was reading an article related to insert tuning as Oracle insert tuning (http://www.dba-oracle.com/t_insert_tuning.htm). Similarly, can I tune the MERGE statement as below:
alter session enable parallel dml;
merge /*+ parallel(contract_dim,10) append */
into TBL_NM A
using (select 1 from dual) B
on (col1 = to_date(:v,'YYMMDD') and col2 = :v and col3 = :v and col4 = :v)
when matched then
update set col5 = :v, col2 = col2+ :v, col3 = col3 + :v
when not matched then
insert (col1, col2, col3, col4, col5, col6, col7, col8)
values (to_date(:v,'YYMMDD'),:v,:v,:v,:v,:v,:v,:v)
Please share your views with explanations and any other suggestion for tuning the MERGE,