Solved

How can I execute stored procedures in parallel from a stored procedure?

Posted on 2008-06-17
5
2,267 Views
Last Modified: 2013-12-07
I need to run in parellel multiple stored procedures with in a stored procedure to attain better performance. Can someone please provide sample code?
0
Comment
Question by:psaju
[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
  • 3
5 Comments
 
LVL 4

Expert Comment

by:Fekrat
ID: 21810566
Use one of Oracle's prepackaged APIs, the DBMS_JOB package, to submit multiple jobs to a job queue and then run them in parallel.
0
 
LVL 4

Expert Comment

by:Fekrat
ID: 21810597
This is an example code i found on the web for a procedure that is not done in parallel
declare
   vStart number;
begin
   vStart := dbms_utility.get_time;
   
   Maintenance.RebuildIndex('ORDERS_PK', 'NOLOGGING PARALLEL');
   Maintenance.RebuildIndex('SALES_PK',  'NOLOGGING PARALLEL');
   Maintenance.RebuildIndex('ORDERS_AK1','NOLOGGING PARALLEL');
   Maintenance.RebuildIndex('SALES_AK1', 'NOLOGGING PARALLEL');
   
   dbms_output.put_line('Elapsed time: ' ||
      round((dbms_utility.get_time - vStart)/100, 2) || ' hsecs' );
end;
/

Open in new window

0
 
LVL 4

Accepted Solution

by:
Fekrat earned 500 total points
ID: 21810599
The following is the version of the code after using the dbms_job package. Hope this helps
declare
 
   vJob number;
 
begin
   dbms_job.submit(job  => vJob,
                   what => 'Maintenance.RebuildIndex(''ORDERS_PK'',
                    ''NOLOGGING PARALLEL'');');
   dbms_output.put_line('Index ORDERS_PK: Job ' || to_char(vJob));
   
   
 
   dbms_job.submit(job  => vJob,
                   what => 'Maintenance.RebuildIndex(''SALES_PK'',
                    ''NOLOGGING PARALLEL'');');
   dbms_output.put_line('Index SALES_PK: Job ' || to_char(vJob));
 
                    
                    
      dbms_job.submit(job  => vJob,
                   what => 'Maintenance.RebuildIndex(''ORDERS_AK1'',
                    ''NOLOGGING PARALLEL'');');
   dbms_output.put_line('Index ORDERS_AK1: Job ' || to_char(vJob));
   
   
 
   dbms_job.submit(job  => vJob,
                   what => 'Maintenance.RebuildIndex(''SALES_AK1'',
                    ''NOLOGGING PARALLEL'');');
   dbms_output.put_line('Index SALES_AK1: Job ' || to_char(vJob));
   
   commit;   
end;
/

Open in new window

0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
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.  …
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…

728 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