UPDATE APA_Pended_Demand APD
INNER JOIN APA_Generic_Demand_Details AGD
ON APD.demandID = AGD.demandID
SET APD.genericDemandId = AGD.genericDemandId
WHERE
APD.isPend = 1
AND COALESCE(AGD.genericDemandId, '') != ''
AND APD.reactivateDate > UTC_TIMESTAMP()
AND AGD.status < 300
AND APD.ID BETWEEN 1 AND 10000
I am using the above code for update about 3,00,000 rows and when I am trying to do that we are getting hanged or timeout error.The indexes are properly used but getting hanged.
So can anyone please help me to get this sorted out
解决方案
Once you've removed the blank values, I suspect that covering indexes on
(demandID,isPend,reactivateDate) and (demandID,genericDemandId,status) will help, instead of whatever you've currently got