spring-projects / spring-projects/spring-batch

Optimized JdbcPagingItemReader configuration for process indicator pattern [BATCH-2317]

Open
#1,284 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: infrastructure related-to: item-readers-writers related-to: performance status: waiting-for-triage type: enhancement
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

Jimmy Praet opened BATCH-2317 and commented

For a new project I'm currently evaluating the performance of using JdbcPagingItemReader versus JdbcCursorItemReader.

The application will make use of a process indicator column in the input table, so saveState="false" will be configured.

In my tests the JdbcCursorItemReader is way faster (5x) than the JdbcPagingItemReader. But this is mostly due to the fact that the JdbcCursorItemReader is doing a simple "SELECT FROM

WHERE AND processed = 0".

The JdbcPagingItemReader however is doing "SELECT FROM

WHERE AND processed = 0 AND > ORDER BY ASC FETCH FIRST 1000 ROWS ONLY".

When working with a process indicator column these " > " and "ORDER BY ASC" clauses are actually not required.

After doing some local hacking to the JdbcPagingItemReader and PagingQueryProvider to remove the sort key condition and order by clause from the query, the performance is comparable to that of JdbcCursorItemReader for this scenario.

The process indicator column is a pattern that is being promoted in the spring batch reference manual, so I think it would be nice to have both standard JDBC reader implementations support this pattern in a performant way.


No further details from BATCH-2317

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading JdbcPagingItemReader and PagingQueryProvider, then trace how the paging query adds the sort-key condition and ORDER BY clauses. The issue's requested outcome is support for a process-indicator configuration that omits those clauses while preserving normal paging behavior; compare the generated queries with the examples in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, sql
Domain
backend, database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.