SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Slow query across databases on same server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

thenearfuture
Starting Member

35 Posts

Posted - 02/28/2013 :  09:50:26  Show Profile  Reply with Quote
Hi,

We recently created a new database and moved some of our tables there. Whenever we write a query using tables from both databases, the queries take much longer than if the tables were in the same DB. The databases are both on the same server. Does anyone have any idea what might be happening?

Example: The first one takes a lot longer than the second one, and there is an index on column a in all tables.


SELECT top 10 *
FROM   DB1.dbo.Table1
       INNER JOIN DB2.dbo.Table2
       ON     Table1.a = Table2.a



SELECT top 10 *
FROM   DB1.dbo.Table1
       INNER JOIN DB1.dbo.Table2
       ON     Table1.a = Table2.a



Any suggestions are much appreciated.

Thank you.

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 02/28/2013 :  10:18:53  Show Profile  Reply with Quote
have a look at execution plan and identify the time consuming steps

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000