Question

I have been trying to de-dupe a table by relating an ID from table 2 to table 1. I want to use the DELETE function but it keeps timing out (for whatever reason, the index, the large amount of data, etc.) I know this can be done in a rather quick and easy fashion but I just can't seem to get it to work.

DELETE *
FROM `TABLE 1`
WHERE EXISTS (select *
              from table2
              where t2.Client_Code = t1.Client_Code and t2.`account#` = t1.`account#`
             );

So as you can see, I want to delete where table1's client code is = to table2's client code, table1's account# is = to table2's account# etc. When I try and run this query, SQLYOG becomes stagnant and does not process. I even let it try and do it's thing for a few hours and no progress. Is there anything I can do to make this happen? I see the admin run queries like this all the time with ease.

Was it helpful?

Solution

Try to add an index over t2, on attributes Client_Code and account#. This may improve the selection on the inner query.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top