I have a DB2 SELECT query which takes a very long time to complete. Is there a much simpler way to achieve the same result?
Select count(*)
from leaveprocess,processlog,leave_type, user_master
where leaveprocess.process_id = processlog.process_id
and user_master.user_id = leaveprocess.create_id
and leaveprocess.leavetype_id = leave_type.serial_no
and leaveprocess.leave_cust_id=315
and user_master.user_id!=0
and user_master.location_id in (2412,2422,2416,2410,2436,2401)
and user_master.user_id in (
select employee_id from employee where employee_cust_id=1558 and company_id in (178)
)
and leaveprocess.leave_id!=0.
There are approx 60,000 records of employee, but when I remove country_id check (company_id in (178)
) then it working very fast and properly.
Are there some suggestions for improving the speed and optimization of my DB2 Query?