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

SQL Query optimization


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
krsenthil85

New User


Joined: 31 Aug 2007
Posts: 55
Location: bangalore

PostPosted: Thu Feb 07, 2008 12:27 pm
Reply with quote

Hi all,

I am having a requirement to reduce the run time for the job. Using strobe tool i found that one of the query involved in the program is taking time. The query is
INSERT
INTO Table1
SELECT *
FROM Table2
WHERE Col1 = xxxx
AND col2 = 0

Here the subquery is having around 1000's of rows. Please help me to reduce the time for this query in developer point of view and also from dba point of view.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Feb 07, 2008 8:33 pm
Reply with quote

Hello krsenthil85 and welcome to the forums,

How many rows does this process INSERT? Are Col1 and col2 defined as a key in table2? If the process has to do a full table scan to find the matches, that will waste resources.

How much time is it taking? Depending on how many thousands of rows are inserted, the time it takes may be reasonable.

It may help if you clarify the difference between developer and dba "point of view".
Back to top
View user's profile Send private message
vebs

New User


Joined: 27 Oct 2007
Posts: 19
Location: UK

PostPosted: Fri Feb 08, 2008 12:45 am
Reply with quote

There might be two places where you can look for optimization -

a) First one, like Dick suggested, you can check the select query for performance, to reduce time taken. This includes checking for Indexscan, clustering etc.

b) Second, since your job is loading thousands of rows, you can consider changing the INSERT to LOAD. This will reduce time elapsed significantly.

Also, if due to some incorrect INSERT operation, you recieve non-zero SQLCODE, then I believe your job will abend and rest of the rows will also not be loaded until you restart it.

But if you consider using LOAD, all the rows will be loaded EXCEPT those which were invalid, giving you better control on the process. You can later choose to reject those rows, or correct and load them, but your process will not come to a halt.
Back to top
View user's profile Send private message
krsenthil85

New User


Joined: 31 Aug 2007
Posts: 55
Location: bangalore

PostPosted: Tue Feb 12, 2008 9:56 am
Reply with quote

Hi Dick,

Thanks for your description. The answer for your question is, this table is having one of the column as a key value.

I mean Difference b/w developer and DBA point of view is modications on the query is developer task and changing the structure of the table or index is DBA point.

Please let me know if you need more details on this.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top