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.

Stored procedure runs slow

meghaveeNov 10 2014 — edited Nov 10 2014

Hello everyone...i have a store procedure which has a merge command, merging into tables....The procedure was working pretty fast 10-20 secs for 200000 merge , but sometimes it is slow takes 20 mins and it does this consistently after it becomes slow. I observed that, if i delete the table and recreate the table again, it performs like before...any ideas why this is happening...

store procedure code

BEGIN

            --  TABLE 1 --

            MERGE /*+ APPEND */  INTO TABLE1 A USING TEMPTABLE B ON (                

                   B.CHILDCOMPONENTTYPE='001')

            WHEN MATCHED THEN

                 UPDATE  SET A.ALX=B.PARENTCOMPONENT;

               

            -- TABLE 2 --

            MERGE /*+ APPEND */  INTO TABLE2 A USING TEMPTABLE B ON (                                

                  A.BNK_NUMBER = B.CHILDCOMPONENT

                 )

            WHEN MATCHED THEN

                 UPDATE  SET A.CIRCUIT_NUMBER = B.PARENTCOMPONENT  WHERE  B.CHILDCOMPONENTTYPE = '002'

            WHEN NOT MATCHED THEN                           

                 INSERT(BNK_NUMBER,CIRCUIT_NUMBER)VALUES(B.CHILDCOMPONENT,B.PARENTCOMPONENT)  WHERE  B.CHILDCOMPONENTTYPE = '002';

               

            -- TABLE3--

            MERGE /*+ APPEND */  INTO TABLE3 A USING TEMPTABLE B ON (

                 A.CHILDCOMPONENTTYPE = B.CHILDCOMPONENTTYPE AND

                 A.CHILDCOMPONENT = B.CHILDCOMPONENT)

            WHEN NOT MATCHED THEN             

                  INSERT CHILDCOMPONENTTYPE,CHILDCOMPONENT,PARENTCOMPONENTTYPE,PARENTCOMPONENT)

                  VALUES(B.CHILDCOMPONENTTYPE,B.CHILDCOMPONENT,COALESCE(B.PARENTCOMPONENTTYPE,' '),

                  COALESCE(B.PARENTCOMPONENT,' ')) ; 

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2014
Added on Nov 10 2014
6 comments
436 views