0

My application needs to change a value in a table if it is not in a very large set (20,000 items) that come in through an XML API. Obviously, it would be easy to create a solution that would be very slow.

I'd like to know how you might recommend doing this? I'm thinking adding the unique IDs of the items in the XML to a temporary table, then executing a single query:

UPDATE item SET status = "deleted" WHERE id NOT IN (SELECT id FROM keep_items);

What do you think?

4

1 に答える 1

1

I ended up using the solution I presented, which was to create and populate a temporary table while the data was being read, and then ran:

DELETE FROM item WHERE item.id NOT IN (SELECT temp_item.id FROM temp_item);

The result is very fast.

于 2012-11-13T01:10:37.233 に答える