Is bulk update faster than single update in db2?

后端 未结 5 1278
星月不相逢
星月不相逢 2021-01-25 00:59

I have a Table with 10 columns and in that table I have thousands/millions of rows. In some scenario, I want to update more than 10K records at a time. currently my scenario cod

5条回答
  •  悲&欢浪女
    2021-01-25 01:21

    In general, a "bulk" update will be faster, regardless of database. Of course, you can test the performance of the two, and report back.

    Each call to update requires a bunch of overhead, in terms of processing the query, setting up locks on tables/pages/rows. Doing a single update consolidates this overhead.

    The downside to a single update is that it might be faster overall, but it might lock underlying resources for longer periods of time. For instance, the single updates might take 10 milliseconds each, for an elapsed time of 10 seconds for 1,000 of them. However, no resource is locked for more than 10 milliseconds. The bulk update might take 5 seconds, but the resources would be locked for more of this period.

    To speed these updates, be sure that id is indexed.

    I should note. This is a general principle. I have not specifically tested single versus multiple update performance on DB2.

提交回复
热议问题