Combining two UPDATE Commands - Performance ?
- by Johannes
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.