Combining two UPDATE Commands - Performance ?

Posted by Johannes on Stack Overflow See other posts from Stack Overflow or by Johannes
Published on 2010-05-18T21:52:01Z Indexed on 2010/05/18 22:00 UTC
Read the original article Hit count: 233

Filed under:
|
|
|

If I want to update two rows in a MySQL table, using the following two command:

UPDATE table SET Col = Value1 WHERE ID = ID1

UPDATE table SET Col = Value2 WHERE ID = ID2`

I usually combine them into one command, so that I do not to have to contact the MySQL server twice from my C client:

UPDATE table SET Col = IF( ID = ID1 , Value1 , Value2) WHERE ID=ID1 OR ID=ID2

Is this really a performance gain?

Background Information: I am using a custom made fully C written high-performance heavily loaded webserver.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about Performance