高数量的 Ebean 提交

huangapple go评论93阅读模式
英文:

High Number of commits through Ebean

问题

我正在处理一个由于DML操作频繁而导致出现日志文件同步等待事件的应用程序。我们使用ebean框架查询Oracle数据库。我正在寻找减少提交次数的方法。是否建议在事务调用中使用JDBC批处理,使用批处理大小属性?

英文:

I am working on an application with high number for DML operations due to which log file sync wait event is observed. We are using ebean framework for querying the Oracle database. I was looking for a way to reduce the number of commits. Is it advisable to use JDBC batch using batch size attribute for transactional calls.

答案1

得分: 0

是否建议在事务调用中使用带有批大小属性的JDBC批处理。

假设一个事务正在插入、更新或删除多个bean/行,那么简而言之,是的

需要注意的是,就应用程序代码而言,实际的DML执行可以在稍后进行,可以在批大小处进行语句刷新,也可以在提交时进行。这意味着语句可以在应用程序代码中稍后执行(比如在提交时)。

这通常只在应用程序代码确实希抛出异常的情况下才真正重要,例如数据库约束冲突、缺失外键、唯一约束等,且实际上要继续事务。在这种情况下,我们可能需要在应用程序代码中添加显式的transaction.flush(),以确保语句已被执行并且已经写入数据库。

英文:

> Is it advisable to use JDBC batch using batch size attribute for
> transactional calls.

Assuming a transaction is inserting, updating or deleting more that 1 bean/row then in short yes.

The caveat is that in terms of application code the actual execution of DML can occur later with statement flush at batch size, at commit time etc. This means statements can execute later in application code (like at commit time).

This typically only really matters to application code when application code is looking to handle exceptions like db constraint violations, missing foreign keys, unique constraints etc and actually continue the transaction. In this case we might need to add explicit transaction.flush() into the application code to ensure the statements have been executed and hit the database.

huangapple
  • 本文由 发表于 2020年8月14日 21:44:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/63413976.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定