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
 General SQL Server Forums
 New to SQL Server Programming
 joins question

Author  Topic 

basicconfiguration
Constraint Violating Yak Guru

358 Posts

Posted - 2012-09-28 : 13:45:54
declare @computer table (computerid int, computermodel varchar(20))


declare @user table (userid int, computerid int)

insert @computer
select 1, 'xx' union all
select 1, 'yy' union all
select 1, 'zz'


insert @user
select 1, 1 union all
select 2, 2


select c.computerid,
c.computermodel,
u.userid
from
@computer c
join
@user u on u.computerid = c.computerid


select c.computerid,
c.computermodel,
u.userid
from
@computer c
join
@user u on c.computerid = u.computerid



getting a little bit curious about how to use the columns when using a join. I dont know which columns to use first to gain the best performance when doing a join.
I checked the execution plan and both gives me the same execution plan. therefore, I think it doesn't matter the order of the columns in the join. Am i right?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-09-28 : 13:50:50
Ordering doesn't matter.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -