Updated GET_LAST_EXECUTION query for performance
This commit is contained in:
@@ -76,7 +76,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
|
||||
+ " from %PREFIX%JOB_EXECUTION where JOB_INSTANCE_ID = ? order by JOB_EXECUTION_ID desc";
|
||||
|
||||
private static final String GET_LAST_EXECUTION = "SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION "
|
||||
+ "from %PREFIX%JOB_EXECUTION E where JOB_INSTANCE_ID = ? and JOB_EXECUTION_ID in (SELECT max(JOB_EXECUTION_ID) from %PREFIX%JOB_EXECUTION E2 where E.JOB_INSTANCE_ID = E2.JOB_INSTANCE_ID)";
|
||||
+ "from %PREFIX%JOB_EXECUTION E where JOB_INSTANCE_ID = ? and JOB_EXECUTION_ID in (SELECT max(JOB_EXECUTION_ID) from %PREFIX%JOB_EXECUTION E2 where E2.JOB_INSTANCE_ID = ?)";
|
||||
|
||||
private static final String GET_EXECUTION_BY_ID = "SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION"
|
||||
+ " from %PREFIX%JOB_EXECUTION where JOB_EXECUTION_ID = ?";
|
||||
@@ -242,7 +242,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
|
||||
Long id = jobInstance.getId();
|
||||
|
||||
List<JobExecution> executions = getJdbcTemplate().query(getQuery(GET_LAST_EXECUTION),
|
||||
new JobExecutionRowMapper(jobInstance), id);
|
||||
new JobExecutionRowMapper(jobInstance), id, id);
|
||||
|
||||
Assert.state(executions.size() <= 1, "There must be at most one latest job execution");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user