SSIS查找转换是否仅缓存相关列?

时间:2018-04-12 15:28:24

标签: ssis etl data-warehouse

我有一个完整的缓存查找,似乎导致失败。它通过Lookup配置中的下拉列表直接指向查找表,我的理解相当于SELECT *。我认为通过更改查找配置以使用SQL语句的结果,我只选择查找值和返回值,这将减少缓存大小。但是,在进行此更改后,我发现缓存大小没有减少。这是因为Lookup足够智能,只能缓存配置的columns部分中指定的列,而不是整个表吗?

1 个答案:

答案 0 :(得分:0)

你是正确的,因为在下拉列表中选择表相当于对表的SELECT *,因此查找将缓存所有数据,无论列使用情况如何。

为了提高性能,我总是建议人们编写一个自定义查询来拉取所需的列,并在适当的位置过滤所检索行的深度。

但是,你的问题让我真的在寻找。这些结果基于SQL Server 2017

我构建了4个包。基本模式使用Adventureworks2014DW的FactInternetSales作为针对CustomerKey上的DimCustomer匹配的查找的驱动程序(OLE DB源)

操作5 - 默认表格选择。没有检索到列 - 只是链接

操作6 - 连接的自定义查询SELECT DC.CustomerKey FROM dbo.DimCustomer AS DC

操作7 - 使用过滤器SELECT DC.CustomerKey FROM dbo.DimCustomer AS DC WHERE EXISTS (SELECT * FROM [dbo].[FactInternetSales] AS FIS WHERE FIS.CustomerKey = DC.CustomerKey )

连接的自定义查询

操作9 - 复制第一个包,这次选择了Customer维度中的所有属性,而不是密钥。这些是结果

我部署了Integration Services目录并在详细日志记录下运行。我使用这样的查询来检索信息指标

SELECT
    OM.operation_id
,   OM.message
FROM
    SSISDB.catalog.operation_messages AS OM
WHERE
    OM.message like 'Data flow task:inform%lookup%'
    AND OM.operation_id > 4
ORDER BY
    OM.operation_id
,   OM.message_time;

以下是我的结果。

operation_id    message
5   Data Flow Task:Information: Lookup has cached 8192 rows.  
5   Data Flow Task:Information: Lookup has cached a total of 18484 rows.  
5   Data Flow Task:Information: The Lookup processed 18484 rows in the cache. The processing time was 0.062 seconds. The cache used 739360 bytes of memory.  
6   Data Flow Task:Information: Lookup has cached 8192 rows.  
6   Data Flow Task:Information: Lookup has cached a total of 18484 rows.  
6   Data Flow Task:Information: The Lookup processed 18484 rows in the cache. The processing time was 0.109 seconds. The cache used 739360 bytes of memory.  
7   Data Flow Task:Information: Lookup has cached 8192 rows.  
7   Data Flow Task:Information: Lookup has cached a total of 18484 rows.  
7   Data Flow Task:Information: The Lookup processed 18484 rows in the cache. The processing time was 0.14 seconds. The cache used 739360 bytes of memory.  
9   Data Flow Task:Information: Lookup has cached 980 rows.  
9   Data Flow Task:Information: Lookup has cached a total of 18484 rows.  
9   Data Flow Task:Information: The Lookup processed 18484 rows in the cache. The processing time was 0.281 seconds. The cache used 38502172 bytes of memory.  

摘要

正如我们所看到的那样,令我震惊的是,必须对源系统进行一些优化/下推,因为前3次运行的缓存大小相同。只有在我使用查找结果时才会增加缓存。

我想说我在2005年到2016年期间启动我的虚拟机并测试这种行为,但没有人有时间这样做。如果这种效率在2012年之前存在,我会感到惊讶。