Hi Vijay, Yes, indeed, a jOOQ Result does not wrap a ResultSet, but consume it and keep an in-memory copy of it. The rationale is documented here: http://www.jooq.org/doc/latest/manual/sql-execution/comparison-with-jdbc
Essentially, in 90% of all JDBC use-cases, this is exactly what you want and the low (in a greater context) memory overhead is perfectly acceptable. With larger result sets, you can fine-tune memory consumption in two ways: - By using ResultQuery.fetchSize ( http://www.jooq.org/javadoc/latest/org/jooq/ResultQuery.html#fetchSize-int-), which translates to JDBC's setFetchSize(). This tells the driver to fetch only a certain number of rows at a time - By using ResultQuery.fetchLazy ( http://www.jooq.org/javadoc/latest/org/jooq/ResultQuery.html#fetchLazy--), which returns an org.jooq.Cursor, or by using ResultQuery.stream ( http://www.jooq.org/javadoc/latest/org/jooq/ResultQuery.html#stream--), which returns a Java 8 Stream. In both cases, the ResultSet is kept open Note, you can also call DSLContext.fetchLazy(ResultSet) or DSLContext.fetchStream(ResultSet), if you prefer working on a JDBC ResultSet directly. Hope this helps. Lukas 2016-01-23 18:27 GMT+01:00 Vijay Ganesan <[email protected]>: > > I use JOOQ for query generation. The generated SQL is executed using JDBC > calls. The resulting JDBC resultset is processed using JOOQ. I notice twice > the memory footprint - one for the JDBC result set and another copy for > JOOQ. See pseudo code below. Is there any way to avoid this? > > org.jooq.Query query = generateJOOQQuery(); > String sql = query.getSQL(); > // execute using standard JDBC > java.sql.ResultSet result = execute(sql); > // process result set using JOOQ > org.jooqDSLContext context = DSL.using(...); > org.jooq.Result<Record> jooqRecords = context.fetch(result); // this seems > to make a copy of the JDBC result set > // iterate through jooqRecords to process results > > Is there any way for org.jooq.Result to be used as just a wrapper over a > java.sql.ResultSet without making copies? > > 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.
