Description
Bug description
We are migrating from Spring Batch 3.x to 5.x and are experiencing performance issues (long delays between each step).
This is on DB2, with a quite large STEP_EXECUTION table (50 million records).
After some digging, I found this to be caused by the GET_LAST_STEP_EXECUTION query, introduced in 62a8f44.
Environment
Spring Batch 5.1.2, Java 21, DB2 v10.5.
Our DBA has not been able to find a solution to improve the performance with an additional index.
What we did find out is that, by removing the ORDER BY, we get the result (typically just a single row in the normal case) in a matter of milliseconds. But with the ORDER BY, it takes ~ 60 seconds.
So a possible workaround would be to remove the ORDER BY and perform the sorting on the java side.
That is something I am currently trying out with the approach of overriding JdbcStepExecutionDao#getLastStepExecution
with a custom implementation as described here. Note that overriding JdbcStepExecutionDao#getLastStepExecution
is not trivial though. Neither JdbcStepExecutionDao
nor JobRepositoryFactoryBean
are very inheritance-friendly.