IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DELETE Query Takes Too Much Time to execute from Batch..


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ManojPrabakaran

New User


Joined: 21 Jan 2009
Posts: 6
Location: Bangaloe

PostPosted: Mon Feb 22, 2010 3:07 pm
Reply with quote

Hi

Submitting the Delete Query From the Batch Takes too much time to execute

DELETE FROM TABLECREATOR.TABLENAME
WHERE CREATE_TIMESTAMP < CURRENT TIMESTAMP - 400 DAYS;
COMMIT;

What May be the reason Behind this...?

Thanks ~ Manoj
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Feb 22, 2010 3:10 pm
Reply with quote

most likely a child table without a decent index.
Back to top
View user's profile Send private message
ManojPrabakaran

New User


Joined: 21 Jan 2009
Posts: 6
Location: Bangaloe

PostPosted: Mon Feb 22, 2010 3:34 pm
Reply with quote

But The table name has an Index created and I can see that in SYSIBM.SYSINDEXES table with all the Values specified.

Also An Entry In the SYSIBM.SYSINDEXPART
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Feb 22, 2010 3:48 pm
Reply with quote

definition of child table : Another table with has a referential integrity defined to this table.
Code:
select * from sysibm.sysrels where reftbcreator = 'TABLECREATOR' and reftbname = 'TABLENAME'

on that table an index should exists on the columns named in sysforeignkeys
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Feb 22, 2010 3:55 pm
Reply with quote

Quote:
DELETE Query Takes Too Much Time to execute from Batch..

how many rows are You deleting??
processing a large number of updates is really a resource hog! from any point of view,
You will have the logs, live and archive full of deleted rows!
and incur the usual processing issues for recoverable resources...

and strange enough, I remember reading somewhere that for deletes the <time> is not really linear ( at least for large numbers of deletes)


there are some things to be aware anyway,
for mass updates You need to evaluate the <convenience> point
i.e what is the limit for doing the updates <online> with dbms calls
or doing them <offline> with unload, cleanup, reload

I will not suggest for Your environment the percentage of hit counts where You should change approach,
only that you must be aware of the issue

From my experience for more than 30% of hits the <offline> approach is a must!
sometimes even less is advisable
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon Feb 22, 2010 4:06 pm
Reply with quote

The DBAs at my installation recommends these bulk deletes, like the one you supposedly are trying to execute, done as unloading the table with a subsequent load of the rows that you want to keep.

In this case only, rows with CREATE_TIMESTAMP >= CURRENT TIMESTAMP - 400 DAYS should be loaded into the table again.

The point in doing it like this is the you probably will have to reorganise the tablespace, and update stats when you delete a large portion of the table.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Mon Feb 22, 2010 4:23 pm
Reply with quote

As this is not a clear matching DELETE, it is bound to take time. You can use REORG with DISCARD option (where you specify the condition) . This is much faster than normal deletes and would be a 2 in 1 deal (DELETE and REORG).
Back to top
View user's profile Send private message
ManojPrabakaran

New User


Joined: 21 Jan 2009
Posts: 6
Location: Bangaloe

PostPosted: Mon Feb 22, 2010 4:37 pm
Reply with quote

Hi All

Thanks All For the Reply..

My intention is to reduce the time and this query is executed through BATCH and the Job will look Like as follows.

System - DB2P and Subsystem -- DDB2P.

//DELREP EXEC DSNTIAD0,SYSTEM=DB2P
DELETE FROM DDB2P.TXXXREPO
WHERE CREATE_TIMESTAMP < CURRENT TIMESTAMP - 400 DAYS;
COMMIT;
//* ------------------------------------------------------
//*
//DELCNT EXEC DSNTIAD0,SYSTEM=DB2P
DELETE FROM DDB2P.TXXXCNTL
WHERE CREATE_TIMESTAMP < CURRENT TIMESTAMP - 60 DAYS;
COMMIT;
//* ------------------------------------------------------
//DELDAT EXEC DSNTIAD0,SYSTEM=DB2P
DELETE FROM DDB2P.TXXXDATA
WHERE CREATE_TIMESTAMP < CURRENT TIMESTAMP - 60 DAYS;
COMMIT;


GuyC

I Executed the Query that you suggested and there is no entry for this tables in the SYSRELS table.

Enrico
The rows are Very Limited. The count in thousands only. Mostly Less than 5000.

KJeld
Every day the REORG AND STATS Job is running for this Table.

Ashimer

Can U Explain little elaborate

Let me know if you have any concerns.

Thanks ~ manoj
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Mon Feb 22, 2010 5:33 pm
Reply with quote

www.mainframesupport.dk/tips/tip0414.html
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Feb 22, 2010 5:40 pm
Reply with quote

Quote:
Can U Explain little elaborate
This is an additional option in REORG where in the REORG card you can mention the selection criteria for the rows which are to be qualified for deletion. Which utility are you using for REORG?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DELETE SPUFI DB2 1
No new posts DSNTIAUL driven delete IBM Tools 0
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts How to get a stack trace on a looping... ABENDS & Debugging 5
No new posts To get the the current time DFSORT/ICETOOL 13
Search our Forums:

Back to Top