Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Performance Issue: Merge Update Insert

Rama_GAug 16 2019 — edited Aug 22 2019

Hi Team,

In my existing code we are using Merge, Update when match and Insert when not matched. However, it is making performance issue. Below is the query.

I am from SAS and hence requesting experts here to show some light on this issue. I am connecting to Oracle through SAS and the query works just as it is like SQL query(you may please ignore Proc sql and disconnect SQL statements).

proc sql;

   connect to ORACLE

   (

       DBEXT=XXXX BUFF=XXXXX PATH=XXXXX DOMAIN="XXXX"

   );

   execute

   (

      MERGE INTO

         Lib1.Target

      USING

         Lib1.Source

      ON

         (

            Source.A_KEY = Target.A_key AND

            Source.P_KEY = Target.P_KEY AND

            Source.R_KEY = Target.R_KEY    )

      WHEN MATCHED THEN UPDATE

         set

            Target.col1= Source.col1,

            Target.col2= Source.col2,

            Target.col3= Source.col3,

       WHEN NOT MATCHED THEN INSERT

         (

            Target.A_KEY,

            Target.P_KEY,

            Target.R_KEY,

         )

         values

         (

            Source.A_KEY,

            Source.P_KEY,

            Source.R_KEY,

         )

   ) by ORACLE;

disconnect from ORACLE;

quit;

PROCEDURE SQL used (Total process time):
real time 30:45.15

I Need to fix the performance.

Can anyone please suggest on this.

Regards

Rama Goteti.

Comments

Gary Graham-Oracle

From a worksheet, using Run Script (F5), you can do something like this if connected to the seeded HR schema:

spool C:\Temp\countries.lst

select /*csv*/ * from countries;

spool off

spool C:\Temp\departments.lst

select /*csv*/ * from departments;

spool off

spool c:\Temp\employees.lst

select /*csv*/ * from employees;

spool off

Hope this helps,

Gary

1 - 1

Post Details

Added on Aug 16 2019
21 comments
8,773 views