-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Improve performance of JdbcStepExecutionDao::getLastStepExecution
#4798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
quaff
commented
Mar 27, 2025
- Use SQL order by clause instead of Java Comparator
- Limit result set size to 1
Alternatively, we could use https://github.com/spring-projects/spring-batch/compare/main...quaff:spring-batch:patch-16?expand=1 |
@@ -100,6 +101,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement | |||
FROM %PREFIX%JOB_EXECUTION JE | |||
JOIN %PREFIX%STEP_EXECUTION SE ON SE.JOB_EXECUTION_ID = JE.JOB_EXECUTION_ID | |||
WHERE JE.JOB_INSTANCE_ID = ? AND SE.STEP_NAME = ? | |||
ORDER BY SE.CREATE_TIME DESC, SE.JOB_EXECUTION_ID DESC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ordering by job execution id while the java comparator was based on the step execution id: .thenComparing(StepExecution::getId, Comparator.reverseOrder());
. Is that intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, fixed now.
1. Use SQL order by clause instead of Java Comparator 2. Limit result set size to 1 Signed-off-by: Yanming Zhou <[email protected]>
The suggested change is basically a revert of the fix for #4657. I'm not sure whether the performance gain is worth it, compared to the risk of re-introducing the previous issue. |
This commit will not query all matched rows but only first row.
|
It's weird, but I'm OK if this PR is rejected. |