0
我試圖在字段'source_key'上使用索引運行以下SQL查詢。在MySQL中,它長時間處於「發送數據」狀態。在MySQL中加速很慢的內部連接查詢
UPDATE clients_test c
INNER JOIN
(
select dob, last_name, soundex(first_name) as soundexfirstname, max(source_key) as keep
from clients_test
group by dob, last_name, soundex(first_name)
having count(*) = 2
) k
ON c.dob=k.dob AND c.last_name=k.last_name AND soundex(c.first_name)=k.soundexfirstname
SET duplicate_key = NULLIF(k.keep, c.source_key),
duplicate = (k.keep = c.source_key);
它應該識別並刪除數據庫表clients_test中的重複記錄。有什麼方法可以使這項工作更快或者將查詢更改爲更高效?
將soundex移動到預先計算的字段中,確定地加快了此查詢的速度。我的低功率雲實例仍然花費了很長時間,但至少在一天之內沒有掛上! – Darren 2011-01-24 23:04:58