有人可以帮助优化下面的查询。 tr_marketshare表只包含84000条记录,查询执行时间为6分19秒。
UPDATE tr_marketshare
INNER JOIN
(SELECT YEAR, MONTH, Door, Category, Category_Sales,Country
FROM tr_marketshare
WHERE Brand = 'Gucci'
AND Account = 'Wojooh'
AND Category='MU') MS
ON tr_marketshare.Door = MS.Door
AND tr_marketshare.Year = MS.Year
AND tr_marketshare.Month = MS.Month
AND tr_marketshare.Account='Wojooh'
AND tr_marketshare.Country = MS.Country
AND tr_marketshare.Category = 'MU'
AND tr_marketshare.Brand <> 'Gucci'
SET tr_marketshare.Category_Sales = MS.Category_Sales;
架构信息如下。
ID和年份是整数。 Category_Sales是浮点数 其余的字段是Varchar类型。
感谢。