Updating database records updating dictionary

Rated 3.91/5 based on 756 customer reviews

But in many cases this only provides a modest improvement as each UPDATE operation still requires a round-trip communication with the database server.In the case where the application server and database server are on different hosts, the round-trip will involve network latency as well.Also, let’s say we want to make updates only for people in the company “Widget Co”.“Bob Jones” appears in both companies, so we need to be careful to identify the company, but we don’t want to have to specify it repeatedly for each row.We can easily contrive for an “updates” table to exist by creating a temporary table and populating it.It is relatively straightforward to populate a table with multiple rows with just one query (or at least, far fewer queries than the number of rows desired).

But we can group the updates according to the value being set, and then do one UPDATE statement per distinct value.OK, that’s great, we have some theoretical approaches for reducing the number of queries, now what?The code required to implement the above logic is sufficiently fiddly that we would probably not want to have to repeat it.A requirement arises in many systems to update multiple SQL database rows.For small numbers of rows requiring updates, it can be adequate to use an UPDATE statement for each row that requires an update.

Leave a Reply