Home » RDBMS Server » Performance Tuning » A question about how to code a procedure to use dbms_parallel_execute package for a huge insert (11.2.0.4 on Linux)
A question about how to code a procedure to use dbms_parallel_execute package for a huge insert [message #672876] Tue, 30 October 2018 09:45 Go to previous message
orausern
Messages: 826
Registered: December 2005
Senior Member
Hi Experts,

I am on Oracle 11.2.0.4 on Linux. I have a query to tune and a scenario in which the query executes fine for smaller data sets and takes more time for huge data set - when it inserts more than one million rows. Our application timeout is 60 seconds and when the data inserts is more than 1 million we are getting timeout. I want to try out dbms_parallel_execute package for this - to change that query to use this package. This question is specifically about this requirement. I am asking this question to specifically know about how to use DBMS_PARALLEL_EXECUTE package to make an insert go in parallel. (Please do not spend your time on other aspects of tuning as I will raise a new question for it if I need help on that.)

For this I have the following setup: Basically a table with 4 column primary key (to mimic my actual issue) and a simpler insert into it from another table holding 1 million rows. But I am stumped at how to use dbms_parallel_execute for this. So many websites I referred are all giving references on DBMS_PARALLEL_EXECUTE for update statements but not for inserts. If someone can share how the insert can be paralleled - and for a table that does not have a single column primary key but a composite 4 column primary key, that will be very useful to me.


Test data setup ...the sql to be made parallel by dbms_parallel_execute is the last sql at the end of the data setup:


 create table test  
   (owner varchar2(30),  
     object_name varchar2(128),  
    object_id number,  
    object_id_2 number,    
 create_date date default sysdate);  
  
  
create table test2  
   (owner varchar2(30),  
     object_name varchar2(128),  
    object_id number,  
    object_id_2 number,    
 create_date date default sysdate);  
  
  
alter table test add constraint test_pk primary key (owner, object_name, object_id,object_id_2);  
  
alter table test2 add constraint test2_pk primary key (owner, object_name, object_id,object_id_2);  
  
insert /*+ append */ into test select owner, object_name,object_id,1 ,sysdate from dba_objects where object_id is not null;  
  
insert /*+ append */ into test select owner, object_name,object_id,2 ,sysdate from dba_objects where object_id is not null;  
  
  
commit;  
  
  
insert /*+ append */ into test select owner, object_name,object_id,3 ,sysdate from dba_objects where object_id is not null;  
  
commit;  
  
insert /*+ append */ into test select owner, object_name,object_id,4 ,sysdate from dba_objects where object_id is not null;  
  
commit;  
  
insert /*+ append */ into test select owner, object_name,object_id,5 ,sysdate from dba_objects where object_id is not null;  
  
commit;  
  
  
17:56:57 testuser@db>select count(*) from test;  
  
  
  COUNT(*)  
----------  
   1141645  
  
  
--actual sql to be made parallel:..this is to be converted to use dbms_parallel_execute packae  

insert  into test2 select owner, object_name,object_id,object_id_2 ,sysdate from test where object_id is not null;  

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: scripts of Oracle SQL Performance Tuning and Optimization
Next Topic: Optimal Chunk size for update of 50M record table
Goto Forum:
  


Current Time: Fri Apr 19 14:40:57 CDT 2024