How to optimize simple linked server select query?
- by tomaszs
Hello,
I have a table called Table with columns:
ID (int, primary key, clustered, unique index)
TEXT (varchar 15)
on a MSSQL linked server called LS. Linked server is on the same server computer. And:
When I call:
SELECT ID, TEXT FROM OPENQUERY(LS, 'SELECT ID, TEXT FROM Table')
It takes 400 ms.
When I call:
SELECT ID, TEXT FROM LS.dbo.Table
It takes 200 ms
And when I call the query directly while being at LS server:
SELECT ID, TEXT FROM dbo.Table
It takes 100 ms.
In many places i've read that OPENQUERY is faster, but in this simple case it does not seem to work. What can I do to make this query faster when I call it from another server, not LS directly?