November 24, 2006 at 10:56 am
In other words...
Are these select statements equivalent (logically, performance-wise, etc.)?
#1:
select A.Apple, B.Bob, C.Cat, D.Dog
from A_Table
left join B_Table B on B.ID = A.B_ID
left join C_Table C on C.ID = A.C_ID
left outer join D_Table D on D.ID = A.D_ID
where A.IQ > 100
#2:
select A.Apple, B.Bob, C.Cat, D.Dog
from A_Table
left outer join D_Table D on D.ID = A.D_ID
left join B_Table B on B.ID = A.B_ID
left join C_Table C on C.ID = A.C_ID
where A.IQ > 100
#3:
select A.Apple, B.Bob, C.Cat, D.Dog
from A_Table
left join B_Table B on B.ID = A.B_ID
left outer join D_Table D on D.ID = A.D_ID
left join C_Table C on C.ID = A.C_ID
where A.IQ > 100
November 24, 2006 at 11:54 am
As B, C and D are joining to A, you should get the same results from all three queries.
The optimizer may behave differently with different join orders. You need to test each case.
You probably want to keep a consistent join order to help avoid deadlocks.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply