我有一个更新查询,执行时间超过 2 小时。该查询根据某些情况同时更新三个表。根据业务需求,更新查询并不复杂。如何优化此查询:查询如下:
UPDATE
atmissuerdata a1
inner join
cbsissuerdata c1 ON ROW( a1.transactionnumber,a1.cardnumber) =ROW( c1.approvalnumber,c1.cardnumber)
INNER JOIN
switchissuerdata s1 ON ROW( a1.transactionnumber,a1.cardnumber) =ROW( s1.approvalnumber,s1.cardnumber)
INNER JOIN
atmlevel1 al1 ON al1.id=a1.id INNER JOIN cbslevel1 cl1 ON cl1.id=c1.id
INNER JOIN
switchlevel1 sl1 ON sl1.id=s1.id
SET
a1.reconstatus =
CASE
WHEN ( ROW( a1.transactionnumber,a1.cardnumber) = ROW( c1.approvalnumber,c1.cardnumber) AND
ROW( a1.transactionnumber,a1.cardnumber) = ROW( s1.approvalnumber,s1.cardnumber) ) AND
( a1.TransactionAmount = c1.TransactionAmountDr AND a1.TransactionAmount = s1.TransactionAmount1 )
THEN 'Y'
WHEN
( ROW( a1.transactionnumber,a1.cardnumber) = ROW( c1.approvalnumber,c1.cardnumber)
AND ROW( a1.transactionnumber,a1.cardnumber) = ROW( s1.approvalnumber,s1.cardnumber) )
AND ( a1.TransactionAmount <> c1.TransactionAmountDr OR a1.TransactionAmount <> s1.TransactionAmount1 )
THEN 'D'
ELSE
a1.reconstatus END,
c1.reconstatus=
CASE WHEN (ROW( a1.transactionnumber,a1.cardnumber) = ROW( c1.approvalnumber,c1.cardnumber)
AND ROW( a1.transactionnumber,a1.cardnumber) = ROW( s1.approvalnumber,s1.cardnumber) )
AND ( a1.TransactionAmount = c1.TransactionAmountDr AND a1.TransactionAmount = s1.TransactionAmount1 )
THEN 'Y'
WHEN ( ROW( a1.transactionnumber,a1.cardnumber) = ROW( c1.approvalnumber,c1.cardnumber) AND
ROW( a1.transactionnumber,a1.cardnumber) = ROW( s1.approvalnumber,s1.cardnumber) ) AND
( a1.TransactionAmount <> c1.TransactionAmountDr OR a1.TransactionAmount <> s1.TransactionAmount1 )
THEN 'D'
ELSE
c1.reconstatus END ,
s1.reconstatus=
CASE WHEN (ROW( a1.transactionnumber,a1.cardnumber) = ROW( c1.approvalnumber,c1.cardnumber)
AND ROW( a1.transactionnumber,a1.cardnumber) = ROW( s1.approvalnumber,s1.cardnumber) )
AND ( a1.TransactionAmount = c1.TransactionAmountDr AND a1.TransactionAmount = s1.TransactionAmount1 )
THEN 'Y'
WHEN ( ROW( a1.transactionnumber,a1.cardnumber) = ROW( c1.approvalnumber,c1.cardnumber)
AND ROW( a1.transactionnumber,a1.cardnumber) = ROW( s1.approvalnumber,s1.cardnumber) )
AND ( a1.TransactionAmount <> c1.TransactionAmountDr OR a1.TransactionAmount <> s1.TransactionAmount1 )
THEN 'D'
ELSE s1.reconstatus END;
请帮帮我..