【发布时间】:2023-02-10 05:57:57
【问题描述】:
我有一个 SSIS 程序包,可以对包含数千万行的表执行查找。似乎默认情况下它将表中的所有行返回到 refTable,然后从 refTable 中选择列与指定参数匹配的位置以查找匹配的查找。是否必须插入 refTable 才能执行此操作?我可以直接用参数过滤掉吗?目前它正在将数百万条记录拉入 refTable 并且浪费了大量时间。这样做是因为正在从该 refTable 中查找多条记录,还是每次它试图查找的每次查找都提取所有这些记录?
这是缓慢的方式和我建议的新方式:
-- old
select * from (SELECT InvoiceID, CustomerId, InvoiceNumber, InvoiceDate
FROM Invoice) [refTable]
where [refTable].[InvoiceNumber] = ? and [refTable].[CustomerId] = ? and [refTable].[InvoiceDate] = ?
-- new
SELECT i.InvoiceID, i.CustomerId, i.InvoiceNumber, i.InvoiceDate
FROM Invoice i
where i.InvoiceNumber = ? and i.CustomerId = ? and i.InvoiceDate = ?
【问题讨论】:
-
您是否使用 SSIS 的查找?如果是这样,您使用什么缓存模式?
-
@raphi5430 部分缓存模式。记录被拉回到 refTable 是因为它对它试图查找的每一行使用相同的记录吗?还是每次执行查找时都会创建大量的 refTable?例如,我正在处理一个包含多张发票的 XML 文件。它每次都在构建那个巨大的 refTable 吗?
标签: ssis