From f6899012543afea1b65e2bb7216b5804188220e0 Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Fri, 10 Sep 2021 16:56:44 +0200 Subject: [PATCH] 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 --- .../core/repository/dao/JdbcStepExecutionDao.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java index d5712fa227..128e257102 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2020 the original author or authors. + * Copyright 2006-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,11 +95,9 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement "SE.WRITE_SKIP_COUNT, SE.PROCESS_SKIP_COUNT, SE.ROLLBACK_COUNT, SE.LAST_UPDATED, SE.VERSION," + " JE.JOB_EXECUTION_ID, JE.START_TIME, JE.END_TIME, JE.STATUS, JE.EXIT_CODE, JE.EXIT_MESSAGE, " + "JE.CREATE_TIME, JE.LAST_UPDATED, JE.VERSION" + - " from %PREFIX%JOB_EXECUTION JE, %PREFIX%STEP_EXECUTION SE" + - " where " + - " SE.JOB_EXECUTION_ID in (SELECT JOB_EXECUTION_ID from %PREFIX%JOB_EXECUTION " + - "where JOB_INSTANCE_ID = ?)" + - " and SE.JOB_EXECUTION_ID = JE.JOB_EXECUTION_ID " + + " 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.START_TIME desc, SE.STEP_EXECUTION_ID desc";