Thanks, yeah I read that. What I'm doing now seems to work pretty well. I
just save the #getSQL and then when I use I do a
sqlContext.resultQuery(sql, [values,...]);

Are you thinking (a) this isn't a good idea or (b) that I am not saving any
cycles? The main reason I'm doing it is that I have several unit tests that
(unfortunately) require some timing to check timeouts and such. The first
few will usually fail because the first time I construct the query its
spends a bit of time creating that query. So whichever test ran first would
fail. Extracting the string as above seemed to fix the warm-up issue.

R.


On Mon, Jun 1, 2015 at 9:32 AM, Lukas Eder <[email protected]> wrote:

> Hello,
>
> There's a short section on optimisation in the manual:
>
> http://www.jooq.org/doc/latest/manual/sql-execution/performance-considerations
>
> Essentially it reads: Don't :)
> (unless you measured stuff and *know* you have a bottleneck).
>
> If you still want to generate SQL strings only once, we generally suggest
> you extract the string and its bind values and execute them via:
>
> - DSLContext.fetch() or DSLContext.execute()
> - JDBC directly
> - Some other tool
>
> You can extract the SQL and bind values using:
>
> - Query.getSQL() (
> http://www.jooq.org/javadoc/latest/org/jooq/Query.html#getSQL--)
> - Query.getBindValues() (
> http://www.jooq.org/javadoc/latest/org/jooq/Query.html#getBindValues--)
>
> As of jOOQ 3.x, Query objects aren't thread safe and must not be used by
> several threads at the same time.
>
> Hope this helps,
> Lukas
>
> 2015-06-01 18:09 GMT+02:00 Robert DiFalco <[email protected]>:
>
>> I'm really enjoying using JOOQ but I have a question about static queries
>> that I use over and over again.
>>
>> I'm not sure why I need to parse these every time they are executed
>> because they never change. I was thinking that in my DAO constructor I
>> would just create them once with #getSQL and then use ResultQuery with
>> saved the string. Of course doing that I lose all the type bindings.
>>
>> I thought that I should be able to save ResultQuery objects instead and
>> reuse them but I think (and I'm not sure why) that they are tied to the
>> connection. Or am I missing something? Is there a way to cache the type
>> safe queries without any database connection context?
>>
>> 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 a topic in the
> Google Groups "jOOQ User Group" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jooq-user/7jqbm98_Ga8/unsubscribe.
> To unsubscribe from this group and all its topics, 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