I have an application which queries data from a 3rd party product. As such, i'm keen not to change the table structure.
Is there a way I can improve efficiency purely on the query side?
My query is:
CallsClosed.Query = @"SELECT COALESCE(ti.FIRST_NAME,'Not Assigned') AS 'Technician', COUNT(*) 'Calls_Closed'
FROM WorkOrder_Threaded wot
INNER JOIN WorkOrder wo ON wot.WORKORDERID=wo.WORKORDERID
LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID
LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID
LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID
LEFT JOIN SDUser td ON wos.OWNERID=td.USERID
LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID
WHERE (wo.COMPLETEDTIME != 0) AND (wo.COMPLETEDTIME != -1) AND (wo.COMPLETEDTIME IS NOT NULL)
AND wo.COMPLETEDTIME >= (UNIX_TIMESTAMP(TIMESTAMP('" + sdChartRange.From + @"')) * 1000)
AND wot.THD_WOID=wot.WORKORDERID
GROUP BY Technician ORDER BY 'Calls_Closed' DESC";
I've run JetProfiler on this, and it looks like the main offender is the size of the wot table. (c. 19k rows)
Any suggestions on where I should start to speed the query up? (Currently takes about 4s to run)
EXPLAIN QUERY
result for that query.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.