Avoid retaining intermediate SQL reporting rows - #23
Merged
Conversation
Owner
|
Thanks, another quick win :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SQL backend currently loads every row into a cloned
DBResultRowcollection, then builds thePeppolReportingItemcollection in a second pass. Large reporting periods retain both the intermediate row/column wrappers and the final objects.Use the existing
DBExecutor.queryAllrow callback to construct each reporting item immediately. The SQL, date bounds, column conversions and eagerIterableAPI remain the same; no dependency, JDBC fetch setting, cursor API or schema changes are needed.The query's
ESuccessis checked before returning the collection. A failed query now throws the already-declaredPeppolReportingBackendException, rather than returning an empty report as before; failure after some rows also cannot expose a partial collection. The database executor continues to log the underlying error.Measured against main
55153b3using local PostgreSQL 18.6 and 200,000 synthetic rows (the existingPeppolReportingTestItems.sendingItemwith distinct end-user IDs), OpenJDK 26.0.2.1/macOS arm64,-Xms64m -Xmx768m, five alternating fresh JVM runs per version:/usr/bin/time -l)All runs returned 200,000 rows with identical checksums. This local workload uses about 146 MiB (23%) less peak process memory. The final collection size is unchanged; this removes intermediate retention, not the eager collection or JDBC driver's own buffering.
Validation:
mvn -B -pl peppol-reporting-backend-sql -am -Dtest=SPITest,PeppolReportingBackendSqlTest -Dsurefire.failIfNoSpecifiedTests=false clean verify: all four reactor modules pass, three selected tests, no failures/errors/skips.