performance - MySQL Update query too slow -


i have update query takes more 2 hours execute. query updates 3 tables simultaneously based on cases . update query little complex based on business requirement. how optimize query: query below :

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)   ,                         row( a1.transactionnumber,a1.cardnumber) = row( s1.approvalnumber,s1.cardnumber) ) ,                  (  a1.transactionamount =   c1.transactionamountdr  ,   a1.transactionamount =   s1.transactionamount1  )                  'y'                    when                          ( row( a1.transactionnumber,a1.cardnumber) = row( c1.approvalnumber,c1.cardnumber)                          , row( a1.transactionnumber,a1.cardnumber) = row( s1.approvalnumber,s1.cardnumber) )                          , (  a1.transactionamount <>   c1.transactionamountdr or a1.transactionamount <>   s1.transactionamount1 )                  'd'                  else                          a1.reconstatus end,          c1.reconstatus=                  case when (row( a1.transactionnumber,a1.cardnumber) = row( c1.approvalnumber,c1.cardnumber)                          , row( a1.transactionnumber,a1.cardnumber) = row( s1.approvalnumber,s1.cardnumber) )                          , ( a1.transactionamount =   c1.transactionamountdr  , a1.transactionamount =  s1.transactionamount1 )                  'y'                  when (  row( a1.transactionnumber,a1.cardnumber) = row( c1.approvalnumber,c1.cardnumber)   ,                         row( a1.transactionnumber,a1.cardnumber) = row( s1.approvalnumber,s1.cardnumber) ) ,                  (  a1.transactionamount <>   c1.transactionamountdr    or   a1.transactionamount <>   s1.transactionamount1  )                   'd'                    else                          c1.reconstatus end ,         s1.reconstatus=                  case when (row( a1.transactionnumber,a1.cardnumber) = row( c1.approvalnumber,c1.cardnumber)                  , row( a1.transactionnumber,a1.cardnumber) = row( s1.approvalnumber,s1.cardnumber) )                  , (  a1.transactionamount =   c1.transactionamountdr  , a1.transactionamount =  s1.transactionamount1 )                  'y'                    when ( row( a1.transactionnumber,a1.cardnumber) = row( c1.approvalnumber,c1.cardnumber)                          , row( a1.transactionnumber,a1.cardnumber) = row( s1.approvalnumber,s1.cardnumber) )                          , (  a1.transactionamount <> c1.transactionamountdr  or a1.transactionamount <>   s1.transactionamount1 )                  'd'                    else s1.reconstatus end; 

please me out ..

i move business logic out of sql statement. checks in code , "update atmissuerdata set reconstats='y' id in (1,2,5,4,...)", "update atmissuerdata set reconstats='n' id in (1,2,5,4,...)"

also using index correctly? in mind "inner join cbsissuerdata c1 on row( a1.transactionnumber,a1.cardnumber) =row( c1.approvalnumber,c1.cardnumber)" slow hell. try use ids on joins , have index on it.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -