Hugo Kornelis (11/26/2014)
Sorry for the harsh words, but this is absolute rubbish.The code in option 2 will always do two lookups. One for the EXISTS, and then another one for either the INSERT or the UPDATE. The code in option 1 will do a single lookup if the row is already there (for the UPDATE), and then only do a second action when the row was not there. So on average, this code is 50% faster (assuming an equal chance of the row being new or already present).
The only correct answer is option 1.
The links provided are bogus. They are about a different comparison: no UPDATE involved, and the WHERE clause was not on the primary key.
Actually, given that the question was which method is fastest for the INSERT, then option 2 is correct. If the question were "Which method is most efficient for adding and updating data in this table," then you would be correct.
Don Simpson