Hi
I need to clean a MySql database table of duplicated emails.
I've written a php script that pulls in a SELECT query of the table containing 1 of each of the dupes then parses over the array to remove all items that match the Email but not the ID of this query
The problem is that it takes too long. Our dedicated server is set to timeout after 120 seconds (standard is 30) so I need this to take place as fast as possible.
Realistically the table will only contain a few duplicates but potentially the list could be all dupes so it needs to be able to handle all 100'000 rows.
If anyone can help optimise this process, your help would be greatly appreicated.
Thanks in advance
Am I jumping the gun, Baldrick, or are the words 'I have a cunning plan' marching with ill-deserved confidence in the direction of this conversation?
I need to clean a MySql database table of duplicated emails.
I've written a php script that pulls in a SELECT query of the table containing 1 of each of the dupes then parses over the array to remove all items that match the Email but not the ID of this query
The problem is that it takes too long. Our dedicated server is set to timeout after 120 seconds (standard is 30) so I need this to take place as fast as possible.
Realistically the table will only contain a few duplicates but potentially the list could be all dupes so it needs to be able to handle all 100'000 rows.
If anyone can help optimise this process, your help would be greatly appreicated.
Thanks in advance
Code:
$dupeList= mysql_query("SELECT ID, Emails, Count(Emails ) FROM Contacts GROUP BY Emails HAVING (Count(Emails ) > 1)",$con);
while ($row = mysql_fetch_array($dupeList)){
mysql_db_query("dblists","DELETE FROM Contacts WHERE Emails ='".$row['Emails']."' AND ID <> '".$row['ID']."'",$con);
}
Am I jumping the gun, Baldrick, or are the words 'I have a cunning plan' marching with ill-deserved confidence in the direction of this conversation?