Welcome to WebmasterWorld Guest from 54.227.110.209

Forum Moderators: open

Message Too Old, No Replies

performance issue for JOIN between different

databases in MSSQL?

     

LifeinAsia

7:02 pm on May 27, 2009 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



In MS SQL, we have 2 databases on the same server (same instance of SQL Server): DB1 (with table TableA), DB2 (with table TableB).

We currently do a JOIN across the databases, e.g.:
SELECT a.Field1, b.Field2
FROM TableA a INNER JOIN DB2.[dbo].TableB b ON a.ID=b.ID

Would there be any significant performance gain by moving TableB to DB1? And then we would just do:
SELECT a.Field1, b.Field2
FROM TableA a INNER JOIN TableB b ON a.ID=b.ID

da_pinky

10:59 pm on May 27, 2009 (gmt 0)

10+ Year Member



i havent used ms sql since 2005, but it shouldnt make a big difference. depends on a lot of other things as well, like how many records do you have in each table, are they in cache etc.
i guess a.ID and b.ID already has an index on it?

LifeinAsia

11:23 pm on May 27, 2009 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Yup- indexed. I finally copied the tables (the above example was simplified somewhat) in question over to the other database and ran some comparison tests.

No difference that I could see. Which is nice- now I don't have to go back and do a lot of recoding!

 

Featured Threads

Hot Threads This Week

Hot Threads This Month