On 2013-10-08 11:42, Lukas Eder wrote:
In SQL, some expressions are "deterministic" (in the Oracle sense of the word), and some expressions are constant. Both expression attributes propagate through expressions. If a function F is deterministic, then "F(A, B)" is deterministic only if both A and B are also deterministic expressions. This can be further expanded to constants. If F is deterministic, then "F(A, B)" is constant only if A and B are constant expressions. Bind values are constant expressions for a single query execution. Thus, it would be possible to pre-process a SQL statement, substituting all constant expressions by their constant value. E.g. CAST(? AS BIGINT) could be substituted by the actual converted bind value. Alternatively, such expressions could be pre-calculated once and cached for a single query execution, similarly to what Oracle does with scalar subquery caching (http://blog.jooq.org/2011/09/02/oracle-scalar-subquery-caching/)
We do function determinism and constant propagation in the Statement case, but not so much in the PreparedStatement case. If you feel like looking at improving the situation, feel free to have a poke around, I'm happy to answer questions about how the code is structured.
-- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/groups/opt_out.
