Arul Sidthan
Arul Sidthan

Reputation: 176

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

PFB my query plan

enter image description here

My Query output

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

enter image description here

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 

Upvotes: 1

Views: 180

Answers (2)

Baz Guvenkaya
Baz Guvenkaya

Reputation: 1562

You may also try UPDATE STATISTICS

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

Upvotes: 1

Vignesh Kumar A
Vignesh Kumar A

Reputation: 28403

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' 

Upvotes: 1

Related Questions