MySQL Forums
Forum List  »  Newbie

Re: subtle performance question - simple query
Posted by: Phillip Ward
Date: July 17, 2014 05:34AM

Quote

-- are these equivalent when an update is happening (I.E. isRead was 0 to start)?
-- are these equivalent when an update is not happening (I.E. isRead was already 1 to start)?
Basically, yes.
Mysql first has to find rows that match your where clause - since userFrom and userTo are indexed, there's a really quick route for the database engine to get to those records so it will use that by choice. The extra check on isRead will involve "skipping" across from the Index to the Table to test the extra field, but that shouldn't be much of an overhead, at least not compared to the actual update.
The only difference you might see if the number of rows updated - if you include the test on isRead, you might get a "0 rows changed" response if no change is required; without the check on isRead, you should always get "1 row changed" (unless, of course, that combination of fromUser and toUser doesn't exist!)

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: subtle performance question - simple query
July 17, 2014 05:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.