How to delete records without generating redo logs? [message #350522] |
Thu, 25 September 2008 05:11 |
sudheer0886
Messages: 7 Registered: September 2008
|
Junior Member |
|
|
Hi Guru's
I need to delete huge amount of data from a table without actually generating the redo logs.Because in no case I want to rollback again.
So could you provide any solution to do it.
Also please provide me the steps to perform DELETE fastly and efficiently.
Thanks in anticipation
|
|
|
|
|
|
|
Re: How to delete records without generating redo logs? [message #350539 is a reply to message #350522] |
Thu, 25 September 2008 05:57 |
sudheer0886
Messages: 7 Registered: September 2008
|
Junior Member |
|
|
There are 30 table which are linked through DELETE CASCADE constraint which have 10 million records in them.
So I am trying to delete from the parent table and it records are getting deleted in all the tables.
The problem is it is taking more time.
So i want to know whether there is any option like NOLOGGING on delete so that I delete them quikly
|
|
|
|
|
|
Re: How to delete records without generating redo logs? [message #350565 is a reply to message #350562] |
Thu, 25 September 2008 07:53 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
Deleting via CASCADE DELETE constraints is the SLOWEST way to delete data.
TRUNCATE is the best if you want to get rid of every row.
If you want to get rid of >10% of the rows, you will almost certainly find it better to rebuild a copy of the table with CREATE TABLE AS SELECT and omit the unwanted rows.
If you absolutely have to DELETE, use programs to load temporary tables with a list of ROWIDs that you want to remove, and then remove them in a single DELETE statement.
Ross Leishman
|
|
|
|
Re: How to delete records without generating redo logs? [message #350693 is a reply to message #350575] |
Thu, 25 September 2008 22:55 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
INSERT INTO temp1
SELECT pkcols, rowid
FROM tab1
WHERE whatever;
INSERT INTO temp2
SELECT pkcols, ROWID
FROM tab2
WHERE fkcols in (SELECT pkcols FROM temp1);
INSERT INTO temp3
SELECT pkcols, ROWID
FROM tab3
WHERE fkcols in (SELECT pkcols FROM temp2);
DELETE FROM temp3
WHERE ROWID IN (select rowid FROM temp3);
DELETE FROM temp2
WHERE ROWID IN (select rowid FROM temp2);
DELETE FROM temp1
WHERE ROWID IN (select rowid FROM temp1);
Ross Leishman
|
|
|