Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 query

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2015-04-30 : 15:12:04
what is best way to rewrite the join query to improve the performance..


LEFT JOIN [STUDENTINFO] [SINFO]
ON [PINFO].[STID] = [SINFO].[STID]
AND [SINFO].[CODE] = '04'
LEFT JOIN [STUDENTINFO] [SINFO1]
ON [PINFO].[STID] = [SINFO1].[STID]
AND [SINFO1].[CODE] = '05'


THanks for your help in advance..

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-04-30 : 15:13:20
You improve it by having the right indexes on the tables.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2015-04-30 : 16:10:40
THanks for immediate response

The index are created but have performance issues..
Scan count and logical reads is more compared with other tables..

Is there a better way of rewriting the query..
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-04-30 : 19:07:45
The part of the query that you posted is fine. Obviously there's more to your query than just that though. Just because you have indexes on the tables doesn't mean you have the RIGHT indexes for the query. Show us the execution plan and show statistics io output.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -