本文介绍了executeBatch对Prepared语句的有效性如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这个问题,请问这一切:executeBatch方法有多有效?是否有性能基准,说..如果你有1000条记录要插入,使用executeBatch而不是executeUpdate可以节省你x个数据库周期?'

Subject to this question, asks it all:How effective is executeBatch method? Is there a performance benchmark, that says.. 'if you have 1000 records to be inserted, using a executeBatch instead of executeUpdate saves you x amount of database cycles?'

或者这只是一个约定?

Or Is this just a convention?

编辑:
这是我正在使用的:一个DB2 V 8.1托管在Z / OS上,一个Web应用程序将在一个

Here is what I am working with: a DB2 V 8.1 hosted on Z/OS, a web app that would be inserting 80,000 records at one go in it's worst case scenario execution.

推荐答案

不知道你使用的是什么数据库。当我使用db2对此进行测试时,这是我看到的:

Not sure what database you are using. When I ran a test on this using db2 this is what I saw:

要写入数据库:

1插入它花费2500微秒。

1 insert it took 2500 microseconds.

10次插入需要6000微秒。 (每写入600微秒)

10 inserts it took 6000 microseconds. (600 microseconds per write)

10000次插入它需要大约100万微秒。 (每写入100微秒)

10000 inserts it took about 1 million microseconds. ( 100 microseconds per write)

性能达到极限。
这意味着发送消息有很大的开销,并且使用批处理方法可以最小化这一点。当然,发送大量批次的插入/更新有可能在应用程序崩溃时丢失它们。

Performance maxed out there.All this means is that there is a huge overhead in sending messages, and using a batch method minimizes this. Of course, sending inserts/updates in huge batches runs the risk of losing them if the application crashes.

另外注意:精确数字会因您的数据库和设置而异。所以你必须找到自己的甜蜜点。但这给了你一个想法。

Also of note: Exact numbers will vary depending on your DB and settings. So you will have to find your own "sweet spot." But this gives you an idea.

这篇关于executeBatch对Prepared语句的有效性如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 09:48