mysql - Multiple updates or update ... where in -
which version better (performance)?
1. update my_table set my_col = 1 my_id = 100 update my_table set my_col = 1 my_id = 110 update my_table set my_col = 1 my_id = 120 2. update my_table set my_col = 1 my_id in (100, 110, 120)
in case, both ways have equal response time running 3-4 queries.
2nd way faster higher number of queries or updates (bulk updates faster) because reduce,
- creating,binding connections database
- query compilation/optimization task of sql engine
but bulk updates has 1 downside i.e. locking of tables updating multiple records in single statement, table locked duration. perform bulk updates considering acceptable locking period in mind.
Comments
Post a Comment