admin管理员组文章数量:1391929
I have an application that receives a lot of tasks to be executed in the background from AWS SQS.
I noticed that a db logging mechanism is implemented, and it may add around 30 log entries via JPA/Hibernate per task.
Also, it creates a new transaction for each Log ( I don't like it, yet the biz requires every Log to be visible immediately upon query ).
I have been searching for a way to buffer the insertions and make a batch insertion requiring much less transactions.
Here are my research results
- Spring / Hibernate caching works only for reading from DB, not buffering insertions ( maybe I am mistaken ).
- Hibernate batch operations, set the batch size to a suitable size, but I have no control over the query, and not sure if it will periodically flush or can even allow this on a specific entity not all statements.
- Manually create a buffer and manage it, then flush the buffer to DB periodically via background thread. Also the query must go through the buffer to get any logs yet not inserted.
Is there a way except the manual buffer ?
本文标签: hibernateIs there a way to automatically buffer insertions of entities in Spring bootStack Overflow
版权声明:本文标题:hibernate - Is there a way to automatically buffer insertions of entities in Spring boot? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744691280a2620008.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论