gd Beginner

Joined: 05 Apr 2006 Posts: 5 Topics: 2
|
Posted: Tue Apr 10, 2007 12:57 am Post subject: Performance issue in SQL select |
|
|
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 |
|