The following query is working fine (fast) when I use emp.status >= 412
or emp.status <= 412
or without emp.status
filter, but when I use only equal operator, i.e. emp.status = 412
, my query is running too slow.
What's the problem? Could it be some indexing issue? I have created an index on status field.
SELECT emp.empno FROM EMP_STATUS emp WHERE
emp.empno in
(
SELECT schemp.empno FROM sched_emp schemp,sections scts
WHERE schemp.SECTSCODE = scts.SECTSCODE AND schemp.dep_code = scts.dep_code AND scts.years=2014
AND schemp.dep_code = 2
)
and emp.dep_code = 2
and emp.status = 412