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 2008 Forums
 Other SQL Server 2008 Topics
 Slow running query

Author  Topic 

krisrajz
Starting Member

19 Posts

Posted - 2010-11-15 : 05:01:20
One of my peer wrote a query based on multiple tables using joins.

One of the table is in a different database

The query was taking much time and here the suggestions I have made:

1. Create an SP

2. Create a temp table and copy all records from the external db

3. Avoid using Left Join as much as possible and use Inner Join

4. Create and use indexes

5. Remove tables/columns that are not necessary

In this scenario, I would like to suggest to use Covering Index, but how can it be created for multiple tables and a temp table?

Any help would be appreciated

Thank you

Regards

Raj

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-15 : 05:13:04
If the different database is on the same server then there shouldn't be a problem and I see no need to copy the data into a temp table.
And as far as I know a covering index is delimited to one table.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

krisrajz
Starting Member

19 Posts

Posted - 2010-11-15 : 06:53:56
Both the DBs are in different servers!
Go to Top of Page
   

- Advertisement -