Mysql 从另一个表更新一个表要花很长时间

Mysql 从另一个表更新一个表要花很长时间,mysql,sql,Mysql,Sql,我有14k条记录的临时表和500万条记录的主表,我正在使用下面的SQL从临时表更新主表 UPDATE customPricing t1 INNER JOIN customPricingIncremental t2 ON (t1.customerClass=t2.customerClass and t1.customerName=t2.customerName and t1.svcType=t2.svcType and t1.svcDuration=t2.svcDuration and t1.d

我有14k条记录的临时表和500万条记录的主表,我正在使用下面的SQL从临时表更新主表

UPDATE customPricing t1 
INNER JOIN customPricingIncremental t2 ON (t1.customerClass=t2.customerClass and t1.customerName=t2.customerName and t1.svcType=t2.svcType and t1.svcDuration=t2.svcDuration and t1.durationPeriod=t2.durationPeriod and t1.partNumberSKU=t2.partNumberSKU)
SET t1.customerId= t2.customerId, t1.customerNumber= t2.customerNumber, t1.custPartNumber=t2.custPartNumber, t1.sppl= t2.sppl ,t1.priceMSRP= t2.priceMSRP, t1.partnerPriceDistiDvarOEM= t2.partnerPriceDistiDvarOEM, t1.msrpSvcPrice=t2.msrpSvcPrice, t1.partnerSvcPrice=t2.partnerSvcPrice, t1.msrpBundlePrice=t2.msrpBundlePrice, t1.partnerBundlePrice=t2.partnerBundlePrice, t1.startDate=t2.startDate, t1.endDate=t2.endDate, t1.currency=t2.currency, t1.countryCode=t2.countryCode, t1.inventoryItemId=t2.inventoryItemId, t1.flexField1=t2.flexField1, t1.flexField2=t2.flexField2, t1.flexField3=t2.flexField3, t1.flexField4=t2.flexField4, t1.flexField5=t2.flexField5
CustomerClass、customerName、durationPeriod、svcDuration和partNumberSKU都是两个表上的索引,长度仅为10,没有主键/唯一索引

更新表格要花很长时间,最后我得到了timedout

我做错了什么


Nitesh

尝试暂时禁用不一致键: ALTER TABLE自定义定价禁用键

现在运行查询,然后再次启用它们:

ALTER TABLE自定义定价启用键

从mysql客户端或脚本而不是phpmyadmin执行此操作,因为查询可能仅适用于当前会话

此外,还要注意目标表中的任何触发器


阅读更多关于键的信息,你是指索引,因为我没有为两个表定义键吗?是的,来自手册:禁用键告诉MySQL停止更新非唯一索引。