【问题标题】:Linked server query performance链接服务器查询性能
【发布时间】:2013-10-08 19:00:31
【问题描述】:

我正在尝试运行从远程 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 吗?
  • 您发布的内容是否存在性能问题?
  • @Blam 是的,这是需要 20 分钟才能返回结果的查询!
  • @HLGEM 不,你能告诉我更多吗?
  • 那里有两个选择语句。答案与问题一样好。发布问题选择和返回的行数。

标签: sql sql-server tsql linked-server query-performance


【解决方案1】:

我使用 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

【讨论】:

    猜你喜欢
    • 2013-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多