2013-01-10 151 views
2

我有一个制作SSIS包的问题。任何人都可以帮忙吗?
这里是: 我有两个表:A & B,和结构是一样的。但是它们存储在不同的服务器上。SSIS删除重复数据

我已经制作了一个SSIS包来将数据从A转换为B(一次约100万行,这需要一到两分钟)。

之后,我想删除表A的数据,之后被转移到B。我写的SSIS包会遵循这一点。我使用merge joinConditional Split命令来选择相同的数据。

之后,我使用OLE DB命令删除表A的数据(只需使用"Delete RE_FormTo Where ID=?" SQLCommand删除)。它可以工作,但它太慢了!花了大约一个小时才能删除重复的数据!有没有人知道这样做的更有效的方式?

SSIS Package Link

回答

2

执行绑定,因为差SSIS包设计的要慢。 请参考文档Best Practices of SSIS Design

让我来解释一下包装中存在的错误。

1.您正在使用Blocking转换(Sort Component)。这些转换不会重用输入缓冲区,而是为输出创建一个新缓冲区,并且大多数情况下它们比同步组件(如查找,派生列等等)重新使用输入缓冲区。 按照MSDN

Do not sort within Integration Services unless it is absolutely necessary. In 
order to perform a sort, Integration Services allocates the memory space of the 
entire data set that needs to be transformed. If possible, presort the data before 
it goes into the pipeline. If you must sort data, try your best to sort only small 
data sets in the pipeline. Instead of using Integration Services for sorting, use 
an SQL statement with ORDER BY to sort large data sets in the database – mark 
the output as sorted by changing the Integration Services pipeline metadata 
on the data 
source. 

2.Merge加入是semi-blocking transformation这确实阻碍性能,但远低于Blocking transformation

有2种方式中,就可以解决这个问题

  1. 使用Lookup

enter image description here

  • 使用执行SQL任务和写入合并SQL

    DECLARE @T TABLE(ID INT); 
    Merge @TableA as target 
    using @TableB as source 
    on target.ID=source.ID 
    when matched then 
    Delete OUTPUT source.ID INTO @T; 
    
    DELETE @TableA 
    WHERE ID in (SELECT ID 
          FROM @T);