Skip to content
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

Simplify GET_LAST_STEP_EXECUTION #3997

Closed

Conversation

marschall
Copy link
Contributor

Simplify JdbcStepExecutionDao#GET_LAST_STEP_EXECUTION to use an
equi-join instead of an cartesian join and a subselect.

Simplify JdbcStepExecutionDao#GET_LAST_STEP_EXECUTION to use an
equi-join instead of an cartesian join and a subselect.
@marschall
Copy link
Contributor Author

JdbcStepExecutionDao#GET_LAST_STEP_EXECUTION currently uses quite complicated combination of a cartesian join and a subselect.

SELECT
    se.step_execution_id,
    se.step_name,
    se.start_time,
    se.end_time,
    se.status,
    se.commit_count,
    se.read_count,
    se.filter_count,
    se.write_count,
    se.exit_code,
    se.exit_message,
    se.read_skip_count,
    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
    batch_job_execution   je,
    batch_step_execution  se
WHERE
    se.job_execution_id IN (
        SELECT
            job_execution_id
        FROM
            batch_job_execution
        WHERE
            job_instance_id = ?
    )
    AND se.job_execution_id = je.job_execution_id
    AND se.step_name = ?
ORDER BY
    se.start_time DESC,
    se.step_execution_id DESC;

This can be simplified to an equi-join

SELECT
    se.step_execution_id,
    se.step_name,
    se.start_time,
    se.end_time,
    se.status,
    se.commit_count,
    se.read_count,
    se.filter_count,
    se.write_count,
    se.exit_code,
    se.exit_message,
    se.read_skip_count,
    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
         batch_job_execution je
    JOIN batch_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;

This is similar to #3876.

@fmbenhassine fmbenhassine added this to the 5.0.0 milestone Sep 10, 2021
fmbenhassine pushed a commit that referenced this pull request Jan 13, 2022
Simplify JdbcStepExecutionDao#GET_LAST_STEP_EXECUTION
to use an equi-join instead of an cartesian join and
a subselect.

Issue #3997
@fmbenhassine fmbenhassine modified the milestones: 5.0.0, 5.0.0-M1 Jan 13, 2022
@fmbenhassine
Copy link
Contributor

LGTM. Rebased and merged as 8d89a4b. Thank you for your contribution!

fmbenhassine pushed a commit that referenced this pull request Jan 13, 2022
Simplify JdbcStepExecutionDao#GET_LAST_STEP_EXECUTION
to use an equi-join instead of an cartesian join and
a subselect.

Issue #3997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants