2014-08-28 101 views
1

PFB我的查詢計劃我在SQL Server中的查詢,需要很多時間來執行

enter image description here

我需要讓所有的團隊成員基於細節上我的查詢輸出所有分配/主動輪

enter image description here

我想優化我的查詢。 PFB我的查詢。

SELECT Ass.strassociatename, 
     Ass.strphotolink, 
     team.strteamname, 
     team.strteamlogo, 
     edu.streducationalinstitute, 
     rounds.strroundname 
FROM ccs_vas_tbl_associates Ass, 
     ccs_vas_tbl_teams team, 
     ccs_vas_tbl_educationalinstitutes edu, 
     ccs_vas_tbl_rounds rounds, 
     ccs_vas_tbl_roundassignment roundass 
WHERE team.iteamid = 64 
     AND ass.iteamid = team.iteamid 
     AND team.ieducationalinstituteid = edu.iinstituteid 
     AND Ass.icompetitionid = rounds.icompetitionid 
     AND roundass.strroundstatus = 'Assigned' 
     AND roundass.iroundid = rounds.iroundid 
     AND roundass.iteamid = team.iteamid 
+0

你能後的查詢計劃嗎? – thebjorn 2014-08-28 05:56:22

+0

每個表中有多少條記錄並且索引被添加? – 2014-08-28 06:00:43

+0

檢查缺席表上是否存在主鍵。查詢本身似乎很好。 – 2014-08-28 06:00:54

回答

1

可以試穿這個

SELECT Ass.strassociatename, 
     Ass.strphotolink, 
     team.strteamname, 
     team.strteamlogo, 
     edu.streducationalinstitute, 
     rounds.strroundname 
FROM ccs_vas_tbl_associates Ass 
     JOIN ccs_vas_tbl_teams team ON ass.iteamid = team.iteamid 
     JOIN ccs_vas_tbl_educationalinstitutes edu ON team.ieducationalinstituteid = edu.iinstituteid 
     JOIN ccs_vas_tbl_rounds rounds ON Ass.icompetitionid = rounds.icompetitionid 
     JOIN ccs_vas_tbl_roundassignment roundass ON roundass.iroundid = rounds.iroundid AND roundass.iteamid = team.iteamid 
WHERE team.iteamid = 64 AND roundass.strroundstatus = 'Assigned' 
+4

新的連接語法很好,但計算相同。 – TomTom 2014-08-28 06:06:27

+1

其工作正常:)感謝Vignesh – 2014-08-28 06:13:35

相關問題