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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 join speed help
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

United Kingdom
15 Posts

Posted - 02/14/2013 :  04:53:22  Show Profile  Reply with Quote
i have this situation

case when row_number() over (partition by t1.i orderby t2._date desc) = 1 then 1 else 0 end as isCurrent2,
case when row_number() over (partition by t1.i orderby t3._date desc) = 1 then 1 else 0 end as isCurrent3
left outer joun t2 on t1.i = t2.i
left outer joun t3 on t1.i = t3.i
t1.thing = @thing
t2.blah = @blah
or t3.blah = @blah

the speed of this query is critical please can someone tell me if outer applying would be quicker and if you have any other tip or tricks.

All help very much appreciated

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 02/14/2013 :  05:56:42  Show Profile  Reply with Quote
Outer apply may not outperform left joins, but couple of things I can suggest are:

1. Since you have columns t2 and t3 in the WHERE clause, it is effectively an inner join of the 3 tables. If that is not the intention, you should rewrite it to move the where clause on t2 and t3 to the joins, or you might as well specify inner joins.

2. Instead of SELECT *, explicitly list the columns you want to retrieve (and only the columns you need).
Go to Top of Page

Posting Yak Master

United Kingdom
206 Posts

Posted - 02/14/2013 :  07:15:26  Show Profile  Reply with Quote
Provide execution plan details please.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000