SQL Most efficient way to delete with 150000 'OR' statements
We hold a DB of ~350k email addresses for a client.
They have supplied me with a couple of excel spreadsheets with a combined
~150k email addresses they want to remove (long story short, it was a
spammy email list that they had gotten hold of and want to remove the
bounce backs).
Using the wonders of find and replace, I have got a query built to perform
this huge delete but the query takes too long and times out (no surprise
there).
The query I have built is in the form of:
DELETE FROM emaillist
WHERE intListID = 68
AND
(strEmailAddress = "aaaa@aaaa.com"
OR strEmailAddress = "aaab@aaaa.com"
OR strEmailAddress = "aaac@aaaa.com"
......
etc etc etc
......
OR strEmailAddress = "zzzy@zzzz.com"
OR strEmailAddress = "zzzz@zzzz.com"
)
Is there a better way to do this?
No comments:
Post a Comment