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 2000 Forums
 Transact-SQL (2000)
 Order of JOINS and Performance

Author  Topic 

gmetaj
Starting Member

33 Posts

Posted - 2004-12-22 : 10:07:04
Does the order in which Joins are peformed (from left to right) matter whether inner or outer when it comes to performance. Assuming that all indexes are the same but the size of the tables is different?

For example let's assume we have 5 tables, TABLE1, TABLE2, TABLE3, TABLE4, TABLE5.

For example:
SELECT Smth from TABLE1 INNER JOIN TABLE2 on Condition1
INNER JOIN TABLE3 on Condition2
LEFT JOIN TABLE4 on Condition3
INNER JOIN TABLE5 on Condition4.

Does SQL optimize the query and finds the best way to inner join or it starts doing the JOINS from left to right?

Thank you for your your feedback.

Gent

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-12-22 : 10:18:53
it optimizes it.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

gmetaj
Starting Member

33 Posts

Posted - 2004-12-22 : 10:21:49
Hehe, good point however that is not always the case. I did some research after i posted and it seems like the order of inner joins does not matter however when it comes to outer joins than SQL does follow the order that they were put in. So bottom line it seems like a careful thought in the filtering process and joins would make a huge diffence in performance.

quote:
Originally posted by spirit1

it optimizes it.

Go with the flow & have fun! Else fight the flow

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-12-22 : 10:50:48
can you post the link where it says that...

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -