Subject UPDATE/INSERT strategy
Author burmair
Is it better to UPDATE, detect 0 rows affected, then INSERT

or INSERT, detect duplicate key, then UPDATE?

The INSERT will succeed once, while the UPDATE will succeed many
times, so it seems the first choice is better.

Or is there some other way to do this?