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.
Author |
Topic |
alecwh22
Starting Member
15 Posts |
Posted - 2013-02-14 : 04:53:22
|
i have this situationselect *, 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 isCurrent3from t1 left outer joun t2 on t1.i = t2.i left outer joun t3 on t1.i = t3.iwhere t1.thing = @thing and ( 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
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-14 : 05:56:42
|
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). |
|
|
Abu-Dina
Posting Yak Master
206 Posts |
Posted - 2013-02-14 : 07:15:26
|
Provide execution plan details please. |
|
|
|
|
|