MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tuning the SQL QUERY

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Catherine
Beginner


Joined: 30 Aug 2006
Posts: 32
Topics: 15
Location: Chennai

PostPosted: Thu Dec 28, 2006 11:34 pm    Post subject: Tuning the SQL QUERY Reply with quote

Code:


SELECT EMP_NAME, EMP_NO, EMP_SALARY
FROM EMP_DET EMP  LEFT OUTER JOIN SALARY_DETAILS SAL
              ON  EMP.EMP_NO= SAL.EMP_NO
WHERE SAL.EMP_SALARY > 1000

Apart from using a sub-query instead of joins, Is there any way to improve the performance of this query. For larger no: of output data the query above performs Poorly
Back to top
View user's profile Send private message
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Fri Dec 29, 2006 5:06 am    Post subject: Reply with quote

As always in SQL, it's a matter of volume and structure:
Do you have indices supporting your predicates?
Do you have index-only access?
Is your data clustered, i.e. sorted as the indices are defined?
What is the volume of data you have to scan to create your answer set?

And last but not least: What is the EXPECTED elapse time of this query?
Sometimes it is not clear, what work DB2 has to accomplish and therefore the expectations about elapse times are to high.

By the way: To my experience a join is more "effective" than a subselect (if you do not know more about the data than the optimizer via current statistics about the involved DB2 objects).

You see: no simple answers to questions like these.

regards
Christian
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group