How to optimize simple linked server select query?
        Posted  
        
            by tomaszs
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by tomaszs
        
        
        
        Published on 2010-03-16T08:36:42Z
        Indexed on 
            2010/03/21
            12:41 UTC
        
        
        Read the original article
        Hit count: 662
        
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?
© Stack Overflow or respective owner