Skip to content

GH-5040: Add database tips and caveats appendix#5420

Open
won-seoop wants to merge 1 commit into
spring-projects:mainfrom
won-seoop:doc-5040-database-caveats-appendix
Open

GH-5040: Add database tips and caveats appendix#5420
won-seoop wants to merge 1 commit into
spring-projects:mainfrom
won-seoop:doc-5040-database-caveats-appendix

Conversation

@won-seoop

Copy link
Copy Markdown
Contributor

Summary

Closes GH-5040

Adds a new database-tips-appendix.adoc page to the reference documentation documenting database-specific caveats and performance tips that are not enforced by Spring Batch itself but that commonly surprise developers.

Contents

MySQL

JdbcCursorItemReader — streaming vs. in-memory ResultSet

  • By default Connector/J loads the entire ResultSet into memory
  • Option 1: fetchSize(Integer.MIN_VALUE) + verifyCursorPosition(false) for row-by-row streaming
  • Option 2: useCursorFetch=true in JDBC URL with a specific page size

JdbcBatchItemWriter — rewriting batched statements

  • rewriteBatchedStatements=true in the JDBC URL rewrites individual INSERT/UPDATE statements into multi-row form, typically yielding 2×–10× throughput improvement

PostgreSQL

SELECT FOR UPDATE SKIP LOCKED with JdbcCursorItemReader

  • Holding an open cursor while the writer modifies locked rows in the same transaction causes lock conflicts on PostgreSQL
  • Workaround: use JdbcPagingItemReader instead (pages are fetched in separate queries)

Cross-reference to FK indexing

  • Links to the existing schema-appendix.adoc section on FK index recommendations

Test plan

  • Verify AsciiDoc renders without errors
  • Confirm nav entry appears correctly
  • Check xref to schema-appendix.adoc#recommendationsForIndexingMetaDataTables resolves

🤖 Generated with Claude Code

Add a new appendix documenting database-specific caveats and
performance tips for Spring Batch:

MySQL:
- JdbcCursorItemReader streaming: fetchSize=Integer.MIN_VALUE +
  verifyCursorPosition(false), or useCursorFetch=true in JDBC URL
- JdbcBatchItemWriter performance: rewriteBatchedStatements=true
  in the JDBC URL for significant write throughput improvement

PostgreSQL:
- SELECT FOR UPDATE SKIP LOCKED with JdbcCursorItemReader causes
  lock conflicts; use JdbcPagingItemReader instead
- Cross-reference to the FK indexing section in schema-appendix.adoc

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add appendix with database related caveats and performance tips and tricks

1 participant