Solved

Help with BULK COLLECT Update Statement

Posted on 2014-03-31
4
481 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.

Join & Write a Comment

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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 video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

706 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

21 Experts available now in Live!

Get 1:1 Help Now