Solved

Help with BULK COLLECT Update Statement

Posted on 2014-03-31
4
490 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
4 Comments
 
LVL 10

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Trying to get a Linked Server to Oracle DB working 21 70
Oracle DB monitor SW 21 60
error in my cursor 5 41
minium over 4 numeric columns for each row in oracle 2 29
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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 video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

808 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