0

Using this solution I've attempted to use IN and GROUP BY to optimize this query to speed it up. It is still sluggish. The use of the || and also the multiple AND statements seem like there is more I can do to optimize this with a more advanced MySQL query?

SELECT 
    COUNT(HTG_ScheduleRequest.ID) AS current_job,
    HTG_TechProps.EmpNumber, 
    HTG_TechProps.EmpFirstName, 
    HTG_TechProps.EmpLastName,  
    HTG_TechProps.Veh_Number
     FROM HTG_TechProps 
        LEFT JOIN HTG_ScheduleRequest ON HTG_TechProps.EmpNumber = HTG_ScheduleRequest.SSR 
        AND HTG_ScheduleRequest.JobStatus IN (2,5,8,3,4) 
        AND RecordType = '1' 
        AND 
        (HTG_ScheduleRequest.ScheduleDateCurrent = CURDATE() || HTG_ScheduleRequest.ScheduleDateExact = CURDATE())  
        GROUP BY HTG_TechProps.EmpNumber ORDER BY HTG_TechProps.EmpNumber ASC 
Community
  • 1
  • 1
Rocco The Taco
  • 3,695
  • 13
  • 46
  • 79

0 Answers0