Solved

Help with BULK COLLECT Update Statement

Posted on 2014-03-31
4
488 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 76

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now