【问题标题】:Timeout because of multiple JOINs in SSIS由于 SSIS 中的多个 JOIN 导致超时
【发布时间】:2019-11-25 08:25:59
【问题描述】:

我有以下 SQL,我试图在 SSIS 包 ADO.NET 源中运行它。

SQL:

select 
b.itemCode as nimike,
e.OrdCustNum as asiakas,
d.DlvCustNum as asiakas2,
b.qty as maara,
c.Price as m_hinta,
c.CostPrice as o_hinta,
d.SalesRep as kasittelija,
d.orderNum as tilausnro,
d.VatDate as tap_pvm,
c.stock as varasto,
'Delivery' as til_tyyppi
FROM 
"PUB"."DlvLine" b
JOIN "PUB"."slsLine" c
    ON 
        b.itemCode = c.itemCode 
        and b.OrderNum = c.orderNum 
JOIN "PUB"."invLine" d
    ON 
        b.itemCode = d.ItemCode
        and b.InvNum = d.InvNum
        and b.DlvNum = d.DlvNum
        and b.OrderNum  = d.orderNum
JOIN "PUB"."SlsOrder" e
ON
    c.OrderNum = e.OrderNum
WHERE 
d.VatDate > '2019-10-22'
and c.AllDelivered = '1'

30秒后预览结果超时,错误信息:

ERROR [HYT00] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver]Timeout expired.
ERROR [HY000] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Query aborted on user request (7495)

我想知道这是否与多个 JOIN 有关,如果我删除第二个 JOIN 子句,则查询运行良好。我有哪些选择?

任何帮助将不胜感激。

【问题讨论】:

标签: sql tsql join ssis


【解决方案1】:

让我们先过滤invoice line 项目,然后再加入主表。我确定每个 order number, 有多个发票行项目,因为您没有显示任何 amountqty,让我们添加 distinct 发票行。

select 
    b.itemCode as nimike,
    e.OrdCustNum as asiakas,
    d.DlvCustNum as asiakas2,
    b.qty as maara,
    c.Price as m_hinta,
    c.CostPrice as o_hinta,
    d.SalesRep as kasittelija,
    d.orderNum as tilausnro,
    d.VatDate as tap_pvm,
    c.stock as varasto,
    'Delivery' as til_tyyppi
FROM 
"PUB"."DlvLine" b
JOIN "PUB"."slsLine" c
    ON 
        b.itemCode = c.itemCode 
        and b.OrderNum = c.orderNum 
JOIN 
    (select distinct ItemCode, DlvCustNum, SalesRep, orderNum, VatDate, InvNum, DlvNum, orderNum
        from "PUB"."invLine" where VatDate > '2019-10-22') d
    ON 
        b.itemCode = d.ItemCode
        and b.InvNum = d.InvNum
        and b.DlvNum = d.DlvNum
        and b.OrderNum  = d.orderNum
JOIN "PUB"."SlsOrder" e ON
    c.OrderNum = e.OrderNum
and c.AllDelivered = '1'

【讨论】:

  • 我在select distinct 中添加了ItemCode,现在它可以工作了!好东西!
猜你喜欢
  • 1970-01-01
  • 2016-01-12
  • 2011-07-10
  • 2019-04-07
  • 2010-10-02
  • 1970-01-01
  • 2013-03-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多