Solved

Help with BULK COLLECT Update Statement

Posted on 2014-03-31
4
499 Views
Last Modified: 2014-05-17
I'm trying to write a update statement that will update one column in a new table I have made. I am using some pseudo code like below to try and do this, but it is painfully slow. I'm completely new to Oracle, but I have read something about BULK COLLECT and FORALL that is supposed to speed things up. I haven't found an example anywhere trying to do exactly what I'm trying below. Can anyone help me or point me in the right direction? Thanks

UPDATE DB1.NEW_TABLE
SET DB1.NEW_TABLE.REFERENCE_ID =
(SELECT a.REFERENCE_ID
FROM DB2.ORIGINAL_TABLE a
WHERE DB1.NEW_TABLE.ID_NBR = a.actual_value)
0
Comment
Question by:sonofstimpy1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Expert Comment

by:HuaMinChen
ID: 39968384
Try to add index on column actual_value.
0
 

Author Comment

by:sonofstimpy1
ID: 39969071
Unfortunately I don't own the table, so I cannot add an index.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39970245
A loop using a collection and bulk collect will not be faster than native DML.

How many rows do both tables have?
0
 
LVL 28

Accepted Solution

by:
Naveen Kumar earned 500 total points
ID: 39971361
your update is using a correlated subquery right, so why don't you check it is running slow instead of trying to change it to the bulk update etc because if you are going to change it then you have write some code to procedurally iterate through the main table NEW_TABLE
to pick up the required records, then take the value from the another table ORIGINAL_TABLE for that particular records and then transfer the contents to the pl/sql arrays i,e associative arrays/collections accordingly and then run a bulk update to the required updates to the table NEW_TABLE.

It may also not be helpful in terms of performance in doing all the above and hence probably trying to find what is causing your update statement to run slowly and then doing a fix there should do the job here for this kind of update sql performance issue.

Thanks,
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to recover a database from a user managed backup
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question