Reputation: 1529
I created a procedure, which takes some input in the form of an Array, which is being passed from a .NET Web Application.
IN PROCEDURE: I open a cursor containing all data in the table, then fetching data from cursor row by row and apply validation rules on it.
For each row I need multiple hits to DB (almost containing nested queries); if data validation fails then I update remarks
field in same table (by using an update query immediately), and if validation is successful then inserting/updating data in other table.
I tried it on 0.25 Million records, and I noticed that it takes more than one hour to process it.
I need to improve the performance of this Stored Procedure. Please let me know how to achieve this.
I have an idea about this.
Making multiple sets of record (10 k in each set) and then process each set just like the way we use multi threading.
Is this possible? If yes then how?
Upvotes: 1
Views: 2156
Reputation: 5298
There is noting like multithreading in Oracle. If you really need to run something in background(parallel) you need either JOB or SCHEDULER_JOB. You can "theoretically" speedup your sequential(batch) processing by using:
Just keep in mind that "PL" and "SQL are two distinct "virtual" machines and context switches between them are(can be) slow.
Use of parallelism/multithreading is common solution in the Java/.NET world. In Oracle this approach is not used to often.
Upvotes: 3
Reputation: 3499
Very likely, your procedure can be made faster by use of PL/SQL batch processing capabilities. To run code in parallel, look at DBMS_JOB and DBMS_SCHEDULER packages. Also, check if parts of your code can be speed up by Parallel Query and/or Parallel DML.
Line by line is the slowest thing, especially if you used explicit cursor.
Upvotes: 2