开发者

How can I improve the performance of database updates from Java?

I currently have a Java thread to update the database once every few seconds. The database is MSSQL 2005, Java version is 6.0.

There are approximately 800 updates every time. So what I did was setAutoCommit(false) in the biginning and call commit() after 800 executeUpdate() calls. These takes about 500ms.

I also tried using batch mode, and the improvement is marginal. It takes about 250ms now.

Is there any way I c开发者_如何学运维an improve it? 250ms still seems too slow.

The server and the client are in the same data center, latency should be minimum.


You don't explain what you're trying to do, so it's hard to suggest improvements.

One thing you might try is restructuring your dbms schema so you can INSERT rather than UPDATE these rows every few seconds. That should help somewhat. You might be able to use an hourly or overnight DELETE operation to clean out the older data.

Another thing might be to figure out how to structure the data so you're handling fewer than 800 rows. Can you put multiple data items together in a single row. That would let you update fewer rows.

It has to be said, 800 updates in a quarter second is not horrible performance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜