Performance Question: ON DUPLICATE KEY UPDATE vs UPDATE (MySQL)

Is there a performance difference between INSERT INTO ON DUPLICATE KEY UPDATE and UPDATE?

If I know the values ​​that may be UPDATEd - should I use UPDATE, or is it not a big deal?

+5
source share
1 answer

There is a difference.

The query INSERTmust check the constraints on each column to see if they are violated by adding this row. If so, then you need to find the appropriate line to update and perform the update.

The query UPDATEshould only find a string to update and perform the update.

If you know that the string already exists, you should just have UPDATEit.

+8

All Articles