简体   繁体   中英

I have a query in SQL Server, it takes much time to execute

PFB my query plan

在此处输入图片说明

My Query output

I need to get all the team members details based on all the Assigned/Active rounds

在此处输入图片说明

I want to optimize my query. PFB my query.

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 

May try this

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' 

You may also try UPDATE STATISTICS

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM