Hi Tomas,
we have been thinking a bit about conditional execution of calculations
and of subqueries. Currently, our idea for this looks like this:
A LET statement will always assign an expression result to a variable,
so it will need to evaluate its expression, always. If an expression
contains a subquery, the subquery will be executed first, always. There
is no simple way to make the subquery execution conditional, because the
subquery and the calculation (LET assignment) are split into two
independent processing steps.
However, if we introduced a conditional LET statement, we could make
evaluation lazy. A potential syntax could look like this in general:
LET variable = expression IF condition
And with a more concrete example:
LET a = (FOR i IN ... RETURN i) IF type == 'foo'
This could be split into the following nodes:
- a calculation that computes the result for the condition (normally
this will be rather cheap)
- a subquery that will only be executed for values which have the
condition variable set to true or a tru-ish value
- a calculation node that assigns the value to variable "a". this will
only be executed for values which have the condition variable set to
true or a tru-ish value
I think this solution would allow conditional execution, saving the
overhead of unnecessarily executed subqueries. And it could be used for
other things than subqueries, e.g. to avoid expensive function calls etc.
What do you think?
Best regards
Jan
> <mailto:
arangodb+u...@googlegroups.com>.
> For more options, visit
https://groups.google.com/d/optout.