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

Feature: Load data in slices(pagination under hood) #77

Open
CyborTronik opened this issue Jun 8, 2017 · 6 comments
Open

Feature: Load data in slices(pagination under hood) #77

CyborTronik opened this issue Jun 8, 2017 · 6 comments
Labels

Comments

@CyborTronik
Copy link

Considering the fact this library has to be used in Rx architecture, there comes the need to load and process data in slices (pagination).

Lets say you have to process a million of records so you cannot handle all this stuff just using one 'select' operation. You have to load data in bits and process just few rows at time and then load next few rows and process ...

@thomasnield
Copy link
Contributor

thomasnield commented Jun 8, 2017

It sounds like there are many ways to achieve this already using existing RxJava operators. buffer(), flatMap(), etc. Even backpressure natively will prevent all data from being pushed at once. It's not clear what you want RxJava-JDBC to do that Rx doesn't do already.

@CyborTronik
Copy link
Author

if you run a sql query it does request all the data at once and then transform to rx.
But what I mean is to have a way to request data in parts via JDBC and process part by part.
for example what happens when you run a select * from a_table and there you have few millions of rows? do you have enough resources to load this data in memory? There is the deal to load and process data using pagination or some cursor for that, so would be nice to have a built in approach for that.

@davidmoten
Copy link
Owner

Sounds like you are talking about fetchSize. This is supported now, see

https://github.com/davidmoten/rxjava-jdbc#fetch-size.

If you don't set fetchSize then your jdbc driver will use its default (which can be quite small; for Oracle is 10!) so you are unlikely to run out of memory but if you are fetching a lot of records you will make fewer calls to the db by setting fetchSize to a larger value.

@stanisfun
Copy link

Cool. Somehow I've missed that from documentation.
Thanks

@litalk
Copy link

litalk commented Jun 27, 2017

@CyborTronik @stanisfun pay attention that currently fetchsize cannot be set to Integer.MIN_VALUE, which is critical for getting query result as a stream, at least on MySQL.
#78

@jad7
Copy link

jad7 commented Apr 26, 2019

I assume that @CyborTronik means an alternative of JdbcCursorItemReader (from spring batch). This really makes sense, because consumer can work significantly slowly, then producer. And pauses between fetching new data can be more than connection timeout, and you will get an exception. Cursor reader will fix this problem, but it's not easy to implement, because of different DBs has a different syntax (approach) for pagination.

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

No branches or pull requests

6 participants