Spring Batch difference between pageSize and commit-interval

不打扰是莪最后的温柔 提交于 2019-12-30 04:51:12

问题


Whats the relationship/difference between Spring-Batch Reader 'pageSize' property and Writer 'commit-interval'.

I may be wrong but I see a pattern in my application that for every pageSize exceeded I get see one commit being made. Is this true.?

Thanks


回答1:


The commit-interval defines how many items are processed within a single chunk. That number of items are read, processed, then written within the scope of a single transaction (skip/retry semantics not withstanding).

The page-size attribute on the paging ItemReader implementations (JdbcPagingItemReader for example) defines how many records are fetched per read of the underlying resource. So in the JDBC example, it's how many records are requested with a single hit to the DB.

While there is no direct correlation between the two attributes, it's typically considered a good idea to make them match, however they independently provide two knobs you can turn to modify the performance of your application.

With regards to your direct question, if you have the page-size set to the same as the commit-interval, then yes, I'd expect a single commit for each page.




回答2:


Commit interval determines how many items will be processed in a Chunk.

Page size determines how many items will be fetched every time it is needed.

Depending on the numbers you set, the behavior may be the one you describe. They are used for optimization.



来源:https://stackoverflow.com/questions/28806787/spring-batch-difference-between-pagesize-and-commit-interval

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!