2011-08-05 39 views
1

我有临时表和主表500万个记录更新表,我从临时表使用SQL以永远从14K记录另一个

下面
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的表格,两者都没有主键/唯一索引。

永远需要更新表格,最后我会得到超时。

我做错了什么?

Nitesh

回答

0

尝试暂时禁用非唯一键: ALTER TABLE customPricing DISABLE KEYS

现在运行你的查询,然后重新启用它们:

ALTER TABLE customPricing ENABLE KEYS

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

另外,请注意目标表中的任何触发器。

了解更多关于

+0

用键盘,你的意思索引,因为我没有为这两个表 – Nitesh

+0

是定义键,从手动:http://dev.mysql.com/doc/refman/5.1 /en/alter-table.html“DISABLE KEYS告诉MySQL停止更新非唯一索引。” – Baversjo

+0

是的,我试过,但不使用!! .....我最终崩溃了MYSQL服务器 – Nitesh