実行に 2 時間以上かかる更新クエリがあります。クエリは、場合によっては 3 つのテーブルを同時に更新します。ビジネス要件に基づいて、更新クエリは少し複雑です。このクエリを最適化する方法: クエリは次のとおりです。
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;
私を助けてください ..