Let me explain :
Let us assume we have a database "user" :
ID Name Surname
===================
1 John Doe
2 Foo Bar
3 Foo Baz
Now I wanna change all these three rows. I will throw the following insert :
INSERT INTO user (ID, Name, Surname) VALUES (1, 'John', 'Conor') ON DUPLICATE KEY UPDATE ID = 1, Name = 'John', Surname = 'Conor';
INSERT INTO user (ID, Name, Surname) VALUES (2, 'Foo', 'Bar') ON DUPLICATE KEY UPDATE ID = 2, Name = 'Foo', Surname = 'Bar';
INSERT INTO user (ID, Name, Surname) VALUES (3, 'Foo', 'Baz') ON DUPLICATE KEY UPDATE ID = 3, Name = 'Foo', Surname = 'Baz';
Question
Does the command ON DUPLICATE KEY
execute itself if the row before the update was the same ? Meaning, does it will execute for the rows with ID
equal to 2 and 3 even if it should not executes (because it is useless) ? I ask this question for performance issues.