Are there any performance gain with this query:
UPDATE tbl SET field = 1 WHERE field != 1
over this
UPDATE tbl SET field = 1
Does the SQL parser already know that he doenst’ need to update row that already are field = 1 ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If there are just a few fields which are
!= 1, then there are most definitely performance gains in adding theWHEREclause. Even if MySQL did not write the value to disk, it still would need to look at every row to see if it needs to write it or not, but it certainly does not add theWHEREclause by itself.