views:

458

answers:

1

Problem: I have to pull data from a SQL Server database and an Oracle database and put it together in one dataset. The problem I have is: The SQL Server query requires an ID that is only found from the return of the Oracle query.

What I am wondering is: How can I approach this problem in a way such that performance is not harmed?

+1  A: 

You can do this with linked servers or by transferring the data all to one side. It's all going to depend on the volume of data on each side.

A general rule of thumb is to execute the query on the side which has the most data.

For instance, if the set of Oracle IDs is small, but the SQL Server set is large, you make a linked server to the Oracle side and execute this on the SQL Server side:

SELECT *
FROM sqlservertable
INNER JOIN linkedserver.oracletable
    ON whatever

In this case, if the Oracle side is large (or cannot be prefiltered before the need to join with the SQL Server side), the performance will normally be pretty poor - and will improve a lot by pulling the entire table (or the minimal subset you can determine) into a SQL Server table instead and do the JOIN all on the SQL Server side.

Cade Roux