0
我正在解決一個運行很長時間的流程,這個select statemet運行超過30分鐘,當我註釋掉它的各個部分時,它運行速度非常快。我在表格旁邊放置了一個看起來導致問題的表格,其中有兩個**在Empid和ChangeDate上有一個聚集索引(這些列不相鄰)不確定是否重要,也沒有這些表格有超過3000行。我希望有一些簡單的調整帽子需要作出。有什麼我應該在源表中看看?任何建議,將不勝感激。我已經在Google搜索結果中使用了多個輸入連接,但沒有運氣。爲了排除故障我把與(NOLOCK)的。左連接導致頭痛
select
je.EmpID,
max(med.ChangeDate) as Max_Medical_ChangeDate,
max(den.ChangeDate) as Max_Dental_ChangeDate,
max(k.ChangeDate) as Max_401K_ChangeDate,
max(ltd.ChangeDate) as Max_LTD_ChangeDate,
max(std.ChangeDate) as Max_STD_ChangeDate,
max(life.ChangeDate) as Max_Life_ChangeDate,
max(sal.ChangeDate) as Max_Salary_ChangeDate,
max(ltdexe.ChangeDate) as Max_LTDEXE_ChangeDate
max(accid.ChangeDate) as Max_Accid_ChangeDate,
max(cancr.ChangeDate) as Max_Cancr_ChangeDate,
max(hosp.ChangeDate) as Max_Hosp_ChangeDate
from Judge_Emp je WITH(NOLOCK)
left join Medical med on je.EmpID = med.EmpID
left join Dental den on med.EmpID = den.EmpID
left join R401K k on den.EmpID = k.EmpID
left join STDIns std on k.EmpID = std.EmpID
left join LTDIns ltd on std.EmpID = ltd.EmpID
* left join LTDEXEIns ltdexe on ltd.EmpID = ltdexe.EmpID
** left join LifeIns life on ltdexe.EmpID = life.EmpID
* left join Salary sal on life.EmpID = sal.EmpID
left join AF_Accid accid on accid.EmpID=sal.EmpID
left join AF_Cancr cancr on cancr.EmpID=accid.EmpID
left join AF_Hosp hosp on hosp.EmpID=cancr.EmpID
group by je.EmpID
感謝
你是什麼意思「用於故障排除的目的我把(nolock)在」? –