delete on db2 table

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You're deleting 30M out of how many total rows? May be more efficient to rebuild the table with just what you want to keep if the percentage is high enough.
-craig

"You can never have too many knives" -- Logan Nine Fingers
bart12872
Participant
Posts: 82
Joined: Fri Jan 19, 2007 5:38 pm

Post by bart12872 »

chulett wrote:You're deleting 30M out of how many total rows? May be more efficient to rebuild the table with just what you want to keep if the percentage is high enough. ...
Well, the table contains 400M of rows and the most of the rows are real update (80%) insert (20%).
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

OK, that question should always come up when deleting a large quantity of records and wanted to get it out of the way. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
rajendharreddy
Participant
Posts: 46
Joined: Tue Aug 21, 2007 5:39 am
Location: Bangalore, India

Post by rajendharreddy »

Hi,

Since delete is very costly statement, one option to solve the issue is,

1. Load the required data(remaining 370 M records) to a TEMP table.
2. Truncate (or) drop the main table. Following command can be used to truncate the table. This is very fastest method.

ALTER TABLE <SCHEMA.TABLENAME> ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE

3. Insert the TEMP table data to main table (or) Rename the TEMP table to main table.

Thanks..
Post Reply