I'm looking for the optimal way in terms of speed and performance to add new entries to a database.
I'm pulling a feed which results in an array of aprox. 50.000 (50k) entries.
I have a database which already contains quite a lot of the entries and instead of doing a truncate and adding them all, I want to only add the new entries to the database.
Each of the entries in the array has a unique ID so they are easily selected in the database.
I'm thinking the most "optimal" approach would be to iterate the array, then make a select for each element in the array to see if it's already in the database and if it isn't add it to the database.
Something about that does however seem wrong, as it's alot of queries.
Is there a faster/better way to do it?