Skip to content

Commit f689901

Browse files
marschallfmbenhassine
authored andcommitted
Simplify GET_LAST_STEP_EXECUTION
Simplify JdbcStepExecutionDao#GET_LAST_STEP_EXECUTION to use an equi-join instead of an cartesian join and a subselect. Issue #3997
1 parent 74df41d commit f689901

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2020 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -95,11 +95,9 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
9595
"SE.WRITE_SKIP_COUNT, SE.PROCESS_SKIP_COUNT, SE.ROLLBACK_COUNT, SE.LAST_UPDATED, SE.VERSION," +
9696
" JE.JOB_EXECUTION_ID, JE.START_TIME, JE.END_TIME, JE.STATUS, JE.EXIT_CODE, JE.EXIT_MESSAGE, " +
9797
"JE.CREATE_TIME, JE.LAST_UPDATED, JE.VERSION" +
98-
" from %PREFIX%JOB_EXECUTION JE, %PREFIX%STEP_EXECUTION SE" +
99-
" where " +
100-
" SE.JOB_EXECUTION_ID in (SELECT JOB_EXECUTION_ID from %PREFIX%JOB_EXECUTION " +
101-
"where JOB_INSTANCE_ID = ?)" +
102-
" and SE.JOB_EXECUTION_ID = JE.JOB_EXECUTION_ID " +
98+
" from %PREFIX%JOB_EXECUTION JE join %PREFIX%STEP_EXECUTION SE" +
99+
" on SE.JOB_EXECUTION_ID = JE.JOB_EXECUTION_ID " +
100+
"where JE.JOB_INSTANCE_ID = ?" +
103101
" and SE.STEP_NAME = ?" +
104102
" order by SE.START_TIME desc, SE.STEP_EXECUTION_ID desc";
105103

0 commit comments

Comments
 (0)