Skip to content

Support for reading large resultsets [DATAJDBC-356] #578

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

Closed
spring-projects-issues opened this issue Apr 8, 2019 · 4 comments
Closed

Support for reading large resultsets [DATAJDBC-356] #578

spring-projects-issues opened this issue Apr 8, 2019 · 4 comments
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

alpet opened DATAJDBC-356 and commented

Enable support for reading large resultsets (milions of rows). Two suggestions:

  1. With respect of mybatis there is already Cursor that can be wrapped in a stream
  2. With respect of pure Jdbc there is one unmaintained framework implementation jdbc-stream https://github.com/APNIC-net/spring-jdbctemplate-streams that may be usefull.

Without this methods as findAll or findAllByProperty will benefit from having such functionality


No further details from DATAJDBC-356

@spring-projects-issues
Copy link
Author

Marcos Vinicius da Silva commented

I stared working on a solution for this issue. I did not started mybatis support yet and will start working on tests and better documentation / examples, but would like to discuss the solution API and implementation wise.

For this case, I created some support classes to return an SqlRowSet backed by a connected ResultSet and it's DataSource. I did it this way so I can keep track of all resources and close them when appropriated.
On the API side, I created a new @QueryStream annotation, to specify the ResultSet fetchSize and to not break current uses of the API (client code that don't close the resulting Stream).

I would much appraciate some review on this work in progress, as it is my first Spring contribution.

Commit link: detinho@913e8c5

@spring-projects-issues
Copy link
Author

Marcos Vinicius da Silva commented

I opened a pull request so it's easier to track changes and get feedback.
#176

@spring-projects-issues
Copy link
Author

Jens Schauder commented

The problem with directly using the a Stream is that it is very likely not to get properly closed, resulting in leaking of resources.

But if you could build a solution based on ClosableIterator I'd be interested in the PR.

@spring-projects-issues spring-projects-issues added status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement labels Dec 31, 2020
@denniseffing
Copy link

I opened a new pull request for this issue. See #903.

schauder added a commit that referenced this issue Jul 2, 2021
Also us Github issue numbers on tests.

See #578, #971
schauder added a commit that referenced this issue Jul 2, 2021
@schauder schauder linked a pull request Jul 2, 2021 that will close this issue
schauder pushed a commit that referenced this issue Jul 2, 2021
Use queryForStream for streamed query results.
Since ResultSetExtractor cannot be reasonably be used together with streams it falls back to the existing collection behaviour.

Closes #578
Original pull request #903
schauder added a commit that referenced this issue Jul 2, 2021
Also us Github issue numbers on tests.

Original pull request #903
See #578, #971
schauder added a commit that referenced this issue Jul 2, 2021
schauder added a commit that referenced this issue Jul 5, 2021
As suggested by Jay Bryant.

Original pull request #903
See #578, #971
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants