Insert is too slow...... [message #183774] |
Sun, 23 July 2006 10:51 |
rafi_aamiri
Messages: 34 Registered: September 2005
|
Member |
|
|
Hi,
I have created two temp tables. (temp1, temp2)
After that an index is created for temp2.
Then insert statement is executed by using union operator and then inserted into the temp2 table.
Here the data inserted into the temp2 table is very huge around 3 millions records.
It takes nearly 5 hours to complete the insert statement.
I think the index is affecting the performance to degrade.
Please let me know whether disabling the index untill the insert is completed is recommended to improve the performance.
Any help is welcome.
Regards,
A.Mohammed Rafi.
Honeywell Migration Project
New Jersey.
|
|
|
|
Re: Insert is too slow...... [message #183777 is a reply to message #183776] |
Sun, 23 July 2006 11:01 |
rafi_aamiri
Messages: 34 Registered: September 2005
|
Member |
|
|
please find the code for your analysis
drop table temp_ed_prod_completed;
create table temp_ed_prod_completed
(
ed_prod_id char(20) not null CONSTRAINT temppk_ed_prod_completed PRIMARY KEY,
proposed_reg_id char(20) not null,
actual_reg_id char(20) null,
status varchar2(10) not null,
ct integer
);
drop table temp_reg;
create table temp_reg(
reg_id char(20) not null,
item_type int not null,
status int not null,
student_id char(20) not null,
product_id char(20) not null
);
create index tempi_reg_sid_pid on temp_reg (student_id, product_id);
insert into temp_reg (reg_id, item_type, status, student_id, product_id)
select
t.id, oi.item_typ, oi.status, t.student_id, t.product_id
from
tpt_transcript t , tpt_oe_order_items oi
where
t.order_item_id = oi.id and
(
(oi.item_typ = 7 and oi.status in (300, 400, 500)) or
(oi.item_typ = 1 and oi.status in (100, 103, 300, 400, 500))
)
union
select
r.id, oi.item_typ, oi.status, r.student_id, oi.part_id
from
tpt_registration r ,tpt_oe_order_items oi
where
r.id = oi.reg_id and
r.student_id is not null and
oi.status in (300, 400, 500);
commit;
|
|
|
Re: Insert is too slow...... [message #183790 is a reply to message #183777] |
Sun, 23 July 2006 20:55 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
- Create the index after the load, it will make the insert faster.
- Use the APPEND hint to get direct-path load (ie. INSERT /*+append*/ INTO ...)
- Change the CHAR columns to VARCHAR2, search on "CHAR vs VARCHAR2" if you need a reason.
Ross Leishman
|
|
|
Re: Insert is too slow...... [message #183839 is a reply to message #183777] |
Mon, 24 July 2006 02:13 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Unless the two halves of the UNION statement are going to return identical rows, you'd get a noticable performance gain by converting the UNION to a UNION ALL.
The UNION statment is doing a DISTINCT on the data returned, which requires sorting it - that will take a minute or two for 3,000,000 rows.
|
|
|
|
|