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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts GETMAIN/FREEMAIN query Suja.Sai CICS 9 Tue Jan 31, 2017 12:01 pm


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