View previous topic :: View next topic |
Author |
Message |
manojvoona Beginner
Joined: 05 Jan 2006 Posts: 43 Topics: 14
|
Posted: Thu Nov 30, 2006 12:19 pm Post subject: Delete Jobs |
|
|
Hi,
This is regarding the delete jobs.
Our database host data of 45 days. so every day a job runs and deletes the datawhich ever is more than 45 days.
This job is takign more than 2 hours a day and we want to reduce the execution time.
what we thought of is to run the job once in a week. Here the data will be accumulated till 52 days and our job runs on the week end deleting all the data which ever is more than 45 days
Here our question if the job takes 2 hours daily
7 days => 2 * 7 = 14 hours.
Once in a week will it take 14 hour again or is it going to be a considerable saves here.
Thanks in advance. we appreciate all your help
Thanks
Manoj Voona |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Nov 30, 2006 9:21 pm Post subject: |
|
|
manojvoona,
You need to show the query you are using for delete. How are you deleting the rows? using an utility or a pgm with checkpoint restart feature?
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
manojvoona Beginner
Joined: 05 Jan 2006 Posts: 43 Topics: 14
|
Posted: Thu Nov 30, 2006 9:53 pm Post subject: |
|
|
Hi Kolusu,
Here is the query we are using
DELETE
FROM MUS.TUZ41 A
WHERE RCPT_DT < CURRENT DATE - 45 DAYS
AND NOT EXISTS
(SELECT 1
FROM MUS.TUZ02_MONTH_END B
WHERE B.MONTH_END_DT = A.RCPT_DT
)
This is done in the program with just above query.
thanks
Manoj Voona |
|
Back to top |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Fri Dec 01, 2006 6:50 am Post subject: |
|
|
If you have any kind of volume,
and I assume you have because of the time required to do the mass delete,
I suggest you delete over a cursor. The subselect for the EXISTS could be transfered to a COBOL Table - of 365 items - if necessary. And include periodic COMMITs in your cursor processing logic.
To have complete restart capability (so that you can report on the number of rows deleted) you would need a separate item (row in another table, row in same table with unique key, ...) that you would update with your statistics each time before a commit. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
|
manojvoona Beginner
Joined: 05 Jan 2006 Posts: 43 Topics: 14
|
Posted: Sat Dec 02, 2006 6:15 pm Post subject: |
|
|
thanks a lot dbzTHEdinosauer,
Can you please elaborate and explain us. I am pretty new to DB2
Thanks in Advance
Manoj Voona |
|
Back to top |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Sun Dec 03, 2006 11:41 am Post subject: |
|
|
The first WHERE phrase I understand. would you please explain the business logic behind the subselect: Code: | AND
NOT EXISTS (SELECT 1
FROM MUS.TUZ02_MONTH_END B
WHERE B.MONTH_END_DT = A.RCPT_DT
) |
_________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
|
|
|