Hello,

The API usage is correct:

   - fetchSize() overrides the JDBC driver's default, which in the case of
   PostgreSQL is 0 (reading the source code), meaning that all rows are
   fetched in one go by default.
   - You're using jOOQ's fetchStream(), which keeps an open JDBC ResultSet
   internally, so jOOQ also doesn't fetch everything in memory
   - You're correctly wrapping the Stream in a try-with-resources
   statement, to be sure that there are no resource leaks

If you want to validate the behaviour, put some breakpoints into the source
code of the PostgreSQL JDBC driver, or turn on debug logging of the driver.
It should emit some debug information, e.g. in
org.postgresql.core.v3.QueryExecutorImpl.sendExecute()

I hope this helps,
Lukas

2018-03-07 18:15 GMT+01:00 LMey <[email protected]>:

> Hi,
>
> I'm not sure I'm using lazy fetching with streams correctly... I'm using
> Jooq 3.9.6 en Postgresql 9.5.
>
> This is my (simplified) repo method :
>
> public Stream<Example> findLazy() {
>     return dslContext.select(...)
>             .fetchSize(100)
>             .fetchStream()
>             .map(ExampleMapper::apply);
> }
>
>
> And my service method (running in a transaction) :
>
> try (Stream<Example> stream = exampleRepository.findLazy()) {
>     stream.forEach(magic::doStuff);
> }
>
>
> Will this chunk appropriately or load everything into memory ? How does
> this work exactly ? Sadly with postgresql I have not found any way of
> checking if this works.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to