DB2V9ZOS—性能调优 出身背景

DB2V9ZOS—性能调优 出身背景,db2,zos,Db2,Zos,目前我使用的是DB2V9版本。我的一个存储过程正在花时间执行。我查看了BMC apptune,发现了以下SQL。 我们使用三个表来执行以下查询。 帐户表有3413条记录 汇率有1267K的记录 余额为1.13亿 最近有人在查询中添加了以下代码。我想正因为如此,我们才有了问题 AND (((A.ACT <> A.EW_ACT) AND (A.EW_ACT <> ' ') AND (C.

目前我使用的是DB2V9版本。我的一个存储过程正在花时间执行。我查看了BMC apptune,发现了以下SQL。 我们使用三个表来执行以下查询。 帐户表有3413条记录 汇率有1267K的记录 余额为1.13亿

最近有人在查询中添加了以下代码。我想正因为如此,我们才有了问题

AND (((A.ACT <> A.EW_ACT)             
      AND (A.EW_ACT <> ' ')                    
      AND (C.ACT = A.EW_ACT))         
     OR (C.ACT = A.ACT))                
查询
在这个查询中发生了很多奇怪的事情。其中最棘手的是混合显式连接和隐式连接语法;坦率地说,我不确定系统是如何解释它的。您似乎还在输入和输出中使用相同的主机变量;请不要。 还有,为什么你的列名这么短?DB2版本至少支持更长的列名。如果可能的话,请保持人们的理智

我们不能完全解释为什么事情进展缓慢——我们可能需要查看访问计划。同时,这是您的查询,它被重新构造为可能更快的形式:

SELECT CASE WHEN :inputType = a.cuy_type THEN DEC(b.clo_led, 21, 2)
            ELSE DEC(MULTIPLY_ALT(b.clo_led, COALESCE(c.exc_rate, 0)), 21, 2) END
INTO :amount :amountIndicator  -- if you get results, do you need the indiciator?
FROM Account as a
JOIN Balance as b  -- This is assumed to not be a 'left', given coalesce not used
ON b.bnk = a.eig_rtn
AND b.act_type = a.act_type
AND b.bus_date = :ws-date-from
AND ((a.act <> a.ew_act     -- something feels wrong here, but
      AND a.ew_act <> ' '   -- without knowing the data, I don't
      AND c.act = a.ew_act) -- want to muck with it.
     OR c.act = a.act)
LEFT JOIN Exchange_Rate as c
ON c.eff_date = current_date - 1 day
AND c.curcy_from = a.curncy_type
AND c.sta_type = a.sta_type
AND c.curcy_to = :destinationCurrency
WHERE a.cusr_id = :dcl.cust-id
AND a.act = :dcl.act
AND a.eig_rtn = :ws-bnk-id
AND a.act_type = :dcl.act-type
AND a.act_cat = :dcl.act-cat
AND a.sta_type = 'A'
WITH UR
FECTCH FIRST 1 ROW ONLY
其他一些注意事项:

只指定所需的列-在某些情况下,这允许仅索引访问,否则可能需要后续表访问。然而,这在这里可能没有帮助。 coalescc.exc_rate,0感觉有些不对劲-如果不存在汇率,则返回0,否则可能是有效金额。您可能需要返回某种指示符,或者将其设置为普通联接,而不是外部联接。 此外,请尝试此版本,也可以尝试在表之间的条件之外指定主机变量的版本。优化器应该能够自动转换这些值,但在某些情况下可能无法转换实现细节

SELECT CASE WHEN :inputType = a.cuy_type THEN DEC(b.clo_led, 21, 2)
            ELSE DEC(MULTIPLY_ALT(b.clo_led, COALESCE(c.exc_rate, 0)), 21, 2) END
INTO :amount :amountIndicator  -- if you get results, do you need the indiciator?
FROM Account as a
JOIN Balance as b  -- This is assumed to not be a 'left', given coalesce not used
ON b.bnk = a.eig_rtn
AND b.act_type = a.act_type
AND b.bus_date = :ws-date-from
AND ((a.act <> a.ew_act     -- something feels wrong here, but
      AND a.ew_act <> ' '   -- without knowing the data, I don't
      AND c.act = a.ew_act) -- want to muck with it.
     OR c.act = a.act)
LEFT JOIN Exchange_Rate as c
ON c.eff_date = current_date - 1 day
AND c.curcy_from = a.curncy_type
AND c.sta_type = a.sta_type
AND c.curcy_to = :destinationCurrency
WHERE a.cusr_id = :dcl.cust-id
AND a.act = :dcl.act
AND a.eig_rtn = :ws-bnk-id
AND a.act_type = :dcl.act-type
AND a.act_cat = :dcl.act-cat
AND a.sta_type = 'A'
WITH UR
FECTCH FIRST 1 ROW ONLY