Subject Re: Is Update or Insert more slower than an single Update (or insert)
Author Dmitry Yemanov
14.01.2012 16:40, Vander Clock Stephane wrote:

> Thanks to my paranoia, i was thinking like everyone that
> Update or insert
> OR
> Insert
> will be close to the same speed (or very similar)

UPDATE OR INSERT should be nearly the same in speed as UPDATE but it's
surely slower than INSERT, see below.

> so i do the test .... and guess ?
> Update or insert is 2x more slower than insert alone :( :( :(
> 100000 Update or insert => 0.501 ms average insert time
> 100000 insert => 0.300 ms average insert time
> sad but interesting to know !

It tries to update the table using the condition and then (if no rows
were affected) attempts to insert the row, so being slower than a
singleton INSERT shouldn't be a surprise.