OR (or in) almost works as if each OR operand was a different request. That is, it turns into a table scan, and for each row, the database must check each OR operand as a predicate until it finds a match or finishes the operands.
The only reason for this is to make it one logical unit of work. You can also wrap a bunch of deletions in a transaction and commit only after successful completion.
Quassnoi makes an interesting suggestion - use a table - but since it uses INs and ORs, it comes out the same.
But try this one.
Create a new table reflecting the real table. Name it u_real_table. Index it by tag and longTag.
Put all incoming data in u_real_table.
Now that you are ready to do your main thing, instead join the mirror table o the real table on the tag. From the real table, delete all the tag'd lines in the u_real_table file:
delete real_table from real_table a join u_real_table b on (a.tag = b.tag); insert into real_table select * from u_real_table where tag is not null;
See what we did here? Since we only join the tag, there is a better chance of using a tag index.
First, we removed everything new, then added new replacements. We can also do an update here. This is faster depending on the structure of the table and its indexes.
We did not need to write a script for this, we just needed to insert records into u_real_table.
Now we do the same for longTags:
delete real_table from real_table a join u_real_table b on (a.longTag = b.longTag); insert into real_table select * from u_real_table where longTag is not null;
Finally, we clear the u_real_table:
delete from u_real_table;
Obviously, we complete all of every delete / insert pair in a transaction, so that deletion becomes real only when the subsequent insert succeeds, and then we transfer all this to another transaction. Because it is a logical unit of work.
This method reduces your manual work, reduces the likelihood of manual error, and has some chances to expedite the removal.
Note that this means that missing tags and longTags are correctly null, not null or empty.