繁体   English   中英

链接服务器查询性能

[英]Linked server query performance

我试图运行一个查询,该查询从远程oracle服务器检索数据,然后检查所检索的数据是否已存在于我的数据库中,然后将其从结果中删除。

SELECT DISTINCT 
            col1,
            col2, 
        col3, 
        col4 , 
        col5, 
        col6 , 
        col7, 
        col8 , 
        col9 , 
        col10, 
        col11
        FROM remoteserver.tab1 dist
        JOIN remoteserver.tab2 headers
        ON headers.id1 = dist.id2 
        JOIN remoteserver.tab3 vendors 
        ON headers.id1 = vendors.id3
        JOIN remoteserver.tab4 comb
        ON dist.id2 = comb.id4
          where
    cond1 and cond2 and cond3 and cond4
   SELECT DISTINCT
           col1, 
           col2,
           col3,
           col4,
           col5,
           col6,
           col7,
           col8,
           col9,
          col10,
          col11
   FROM myserver.tab1

这只是我正在运行的查询大小的详细说明,问题是要花费很长时间(大约20分钟!)才能获得结果。 关于如何使用链接服务器的不同方法来提高性能或实现相同逻辑的任何建议?

我使用openrowset解决了该问题,它大大提高了性能。

select * from (linkedserver,
'SELECT DISTINCT 
            col1,
            col2, 
        col3, 
        col4 , 
        col5, 
        col6 , 
        col7, 
        col8 , 
        col9 , 
        col10, 
        col11
        FROM remoteserver.tab1 dist
        JOIN remoteserver.tab2 headers
        ON headers.id1 = dist.id2 
        JOIN remoteserver.tab3 vendors 
        ON headers.id1 = vendors.id3
        JOIN remoteserver.tab4 comb
        ON dist.id2 = comb.id4'
          where
    cond1 and cond2 and cond3 and cond4
   SELECT DISTINCT
           col1, 
           col2,
           col3,
           col4,
           col5,
           col6,
           col7,
           col8,
           col9,
          col10,
          col11
   FROM myserver.tab1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM