我在SQL Server中有一个查询,执行需要很长时间

时间:2014-08-28 05:53:21

标签: sql sql-server

PFB我的查询计划

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 

2 个答案:

答案 0 :(得分: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' 

答案 1 :(得分:1)

您也可以尝试UPDATE STATISTICS

http://msdn.microsoft.com/en-AU/library/ms187348.aspx