Please see this http://stackoverflow.com/questions/7753380/performance-implications-for-using-openquery-in-a-view question on stackoverflow, it's a cross over subject and would love a dba's POV
SummaryLet the linked server do as much as possible. LongThe key factor is where the query runs. In this case, it is a trivial SELECT so all rows from a table will be sent down the wire. It doesn't matter. When you add JOINs and WHEREs then it can matter. You want SQL Server to allow the linked server to do as much filtering as possible to reduce the size of the data coming over the network. For example, the 2nd case here should be more efficient.
A limitation of OPENQUERY is that you can't parametrise: so you need dynamic SQL to add WHERE clauses etc. Linked servers performance can be affected by
That is, try not to let SQL Server process the data locally. Note: On my Finally, I've also found that staging the data into a temp table and joining that onto local tables is often better then joining directly onto the OPENQUERY. |
|||
|