简体   繁体   English

具有Oracle的SQL Server链接服务器-问题:选择* x选择列

[英]SQL Server Linked Server with Oracle - Issue: Select * x Select Columns

I have a performance problem with the OPENQUERY on SQL SERVER 2008 R2: When I run: 我在SQL SERVER 2008 R2上的OPENQUERY遇到性能问题:运行时:

select 
*
from openquery([LINKEDSERVER],'
            SELECT
            COLUMN1,COLUMN2,COLUMN3...(45 columns at all)
            FROM ORACLE_TABLE
            WHERE X>Y')

the response time past 5 minutes (yes, 5 minutes). 响应时间超过5分钟(是5分钟)。 But, if I run the same select with one only column on Oracle side: 但是,如果我在Oracle方面仅对一列运行相同的select

select 
*
from openquery([SERVER],'
            SELECT
            COLUMN1
            FROM ORACLE_TABLE
            WHERE X>Y')

the response time is 17 seconds (10.000 records). 响应时间为17秒(10.000条记录)。

Any ideas? 有任何想法吗?

What are the wait events on both sides? 双方的等待事件是什么? What are the query plans? 有哪些查询计划?

Is the process waiting on network traffic? 进程在等待网络流量吗? If so, presumably, 45 columns of data has substantially more data to transmit over the network. 如果是这样的话,那么大概45列数据将具有更多的数据要通过网络传输。 If we assume that it is 45 times more data and that 7 of the 17 elapsed seconds in the faster case is spent on network traffic, then going from one column of data to 45 columns of data would increase the amount of network wait events by 7s * 44 columns = 308 seconds. 如果我们假设数据量增加了45倍,并且在较快的情况下经过的17秒中有7秒花费在网络流量上,那么从一列数据到45列数据将使网络等待事件的数量增加7秒* 44列= 308秒。 So without more information, going from 17 seconds to 5 minutes by increasing the amount of data you're sending over the network by a factor of 45 seems at least potentially reasonable. 因此,如果没有更多信息,将通过网络发送的数据量增加45倍从17秒增加到5分钟似乎至少可能是合理的。

Of course, if you tell us that column1 is a large image and the other 44 columns are CHAR(1) columns that each consume a single byte, then an increase in network traffic wouldn't be a reasonable explanation for the change in performance. 当然,如果您告诉我们column1是一个大图像,而其他44列是CHAR(1)列,每个列消耗一个字节,那么网络流量的增加将不是性能变化的合理解释。

Is column1 indexed? column1索引? If so, perhaps there is a very different plan when you want to fetch all 45 columns. 如果是这样,当您要获取所有45列时,也许会有一个非常不同的计划。 Perhaps the first query plan shows that Oracle simply has to scan a small covering index while the second plan shows that it has to do a much more expensive table scan. 也许第一个查询计划表明Oracle只需扫描一个小的覆盖索引,而第二个计划表明它必须进行更昂贵的表扫描。

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

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