问题
What is the difference between the propertie "FetchSize" and "PageSize" in Spring Batch ? The PageSize is the number of rows to retrieve at a time ? The FetchSize is number of DB calls ?
If my query return 10000 rows, what is the best setting ? If i put PageSize to 1000 and FetchSize to 1000, can you confirm i just need 10 calls for return all rows ? So if i upgrade the number of the propertie PageSize (for example 10.000), the number of DB call is just 1 so running time of the batch is better ?
回答1:
That's correct. With pageSize=1000
and fetchSize=500
, there will be in theory 2 database calls to fetch a single page.
However, the fetchSize
is just a hint to the database driver and can be ignored. So you need to check your database driver's documentation to make sure it behaves as expected in regards to this parameter.
来源:https://stackoverflow.com/questions/58041942/utility-of-fetchsize-and-pagesize-in-reader-spring-batch