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 

Performance issue in SQL select

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


Joined: 05 Apr 2006
Posts: 5
Topics: 2

PostPosted: Tue Apr 10, 2007 12:57 am    Post subject: Performance issue in SQL select Reply with quote

Hi,

I am facing a performance issue in the below SQL:

Code:
SELECT A.emp_name,
       A.emp_no,
       A.emp_addr,       
       A.emp_dept_no,
       A.emp_office_id,
       B.emp_sal,
   .....
   .....     
FROM  emp_det A,
      emp_salary B,
      dept_det C
WHERE  A.emp_office_id = 'AAAAA'
      AND A.emp_no = B.emp_no
      AND A.emp_dept_no = c.dept_no
      AND A.emp_dept_no != 'XXXX'


When I run this SQL it takes lot of time to execute.

If i remove the conditions 'AND A.emp_dept_no = c.dept_no' or 'AND A.emp_dept_no != 'XXXX'' it works fine. But my requirement is that I need both the conditions to be present in SQL.

I replaced the last two conditions with
AND A.emp_dept_no(SELECT dept_no from dept_det where dept_no != 'XXXX')but still its taking time.

I have noticed that whenever I use NOT EQUALS as in last condition, it runs for long time.
I have other method also in my mind: Remove last condition from SQL. check for the value of
emp_dept_no in the program using IF emp_dept_no = 'xxxxx' and skip the processing.

Is there any way to save time without omitting any of the condition above.

Thanks,
Ganesh
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 317
Topics: 50
Location: Germany

PostPosted: Tue Apr 10, 2007 3:52 am    Post subject: Reply with quote

gd,

check explain command, check indexstructure ......
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