jOOQ Result Parallel Stream Thread Safety

73 views
Skip to first unread message

Sahil Takiar

unread,
Aug 2, 2021, 3:26:40 AM8/2/21
to jOOQ User Group
Is it safe to call `parallelStream()` on a `Result<Record>` object in jOOQ?

We have queries where we seen a lot of overhead deserializing results, and we are looking for ways to reduce that overhead.

Most of our queries look something like this:

DSL.using(readOnlyConfiguration)
...
.fetch()
.stream()

Java profilers show a lot of overhead in the fetch() method, but not from executing the actual query, typically in methods like org.jooq.impl.DefaultBinding.get(BindingGetResultSetContext).

So, is it safe to replace `stream()` with `parallelStream()`?

Lukas Eder

unread,
Aug 3, 2021, 2:01:06 PM8/3/21
to jOOQ User Group
Hi Sahil,

Thanks for your message. A jOOQ Result is an ordinary List, currently backed by an ArrayList. Once you have fetched a Result, it is fully materialised in memory, and thus parallelStream() should be safe.

However, it is likely that there is a much better solution / workaround to your problem. Doing something slow in parallel is not a robust solution. May I ask you to provide some more details to what's going on in those DefaultBinding calls? Perhaps it's just a bug, in case of which, you could report it here: https://github.com/jOOQ/jOOQ/issues/new/choose

Thanks,
Lukas

--
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 jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/475389a7-5f14-4155-8368-5542fd65a4bfn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages