Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SQL Query optimization

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: SQL Query optimization
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

Site Director


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

PostPosted: Thu Feb 07, 2008 8:33 pm    Post subject:
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    Post subject:
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    Post subject: Reply to: SQL Query optimization
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us