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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting blob, taking too much time

Status
Not open for further replies.

sikar

Programmer
Jun 4, 2003
15
0
0
US
Hi,

I have a table which stores blob. There are 45,000 records in the table. I have to delete 30,000 records based on some criteria. I have written separate 30k queries, one for deleting one record. It is taking time more than 10 hours to delete all the 30k records. It will be of great help if you can suggest me a fast way to achieve the same.

Thanks
 
Sikar,

Keep in mind that when you "DELETE" rows, Oracle must duplicate the entire contents of the row in an Rollback/UNDO segment in case you decide to issue a "ROLLBACK" command. A "DELETE", therefore, is volumetrically equivalent to an "INSERT" of the deleted data for rollback purposes.

Alternately, an "INSERT" statement generates virtually no rollback since, if you decided to rollbak an INSERT, you are reverting to.......NOTHING.

So, my suggestion to you, since you have half as many rows to KEEP as to DISCARD, try the following:

1) INSERT the 15,000 remaining rows into a table named SIKAR
2) DROP your original table.
3) RENAME the table, "SIKAR" to the name of the old table.

Keep in mind that if you have indexes/PKs/FKs/other constraints on the original table, you will need to re-create/enable those constraints, but it still should be much faster than your DELETE.

And, as with any major maintenance such as this, be certain that you have backedup/exported the subject table(s) before you start messing with them.

Let us know your findings.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
Hi Mufasa,

Thanks a lot for reply. In my case I have separate 30000 queries for deletion and after every query I have commit. So the issue of rollback segment is not there. Since I am deleting row having blob column, it is taking too much time. The overall size of these 30000 rows is approximately 4GB. It is taking approx 12 hours to delete all the 30K rows, one by one, commit at each step. So is there a faster way to do the same?

Thanks
 
Sikar said:
...the issue of rollback segment is not there.
I believe you may be confused, Sikar...If you issue a DELETE command, rollback is an issue. The fact that there are 4GB of deletes makes it a very significant issue since Oracle still must write 4GB of rollback entries, regardless of whether they are individually or collectively committed.


Have you experimented with the suggestion that I made earlier?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top