我有一个从 3rd 方产品查询数据的应用程序。因此,我不想改变表结构。
有没有办法可以纯粹在查询方面提高效率?
我的查询是:
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";
我已经在上面运行了 JetProfiler,看起来主要的罪魁祸首是 wot 表的大小。(约 19k 行)
关于我应该从哪里开始加快查询速度的任何建议?(目前运行大约需要 4s)