Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deletes -- performance issues 1

Status
Not open for further replies.

toddyl

Technical User
Sep 26, 2005
102
US
Hi,

I have several tables where data is being loaded to all day/every day. About once a week I need to remove certain entries from these tables and I have created a procedure that selects the entries to delete and then steps through each table and deletes the appropriate records.

These tables are huge -- millions of rows each -- and the delete appears to be absolutely crawling. The delete is doing a simple:

delete from my_table where my_column = X;

Is there any way I can improve the performance of my delete statement?

Thanks,

toddyl
 
Is there an index on my_column ? How many rows are being deleted as a proportion of the whole table ?
 
Dagon,

Thanks for the reply.
You are indeed correct, there was no index on my_column as in a lot of tables this is a minor entry. It was a convenient way for me to identify the same record in all tables so I used this instead of the primary keys.

I have added indexes to all tables for my_column and the performance has increased.

Thanks,

Tom
 
You also need to answer Dagon's second question. What percentage of the rows are deleted. If you are (for example) deleteing 90% of the rows, a MUCH faster way to delete would be to do the following.

create temp_table as
select *
from my_table
where my_column <> x;

truncate table my_table;

insert into my_table
select * from temp_table;

drop table temp_table;

Bill
Oracle DBA/Developer
New York State, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top