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,

  1. creating,binding connections database
  2. 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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -