The WHERE clause of a query seems to be polluting subqueries.
The WHERE of the outer select is being pushed into the subquery (query optimizer?), but because the subquery depend on all its selected rows rows for correct @variable calculations, moving the outer WHERE inside changes the results. Is this intended behavior, or a bug?
It is intended behavior. Depending on the optimization, not all rows are processed.Maybe it is easier to create a Java function that returns a result set, and use it like a table?
Shouldn't sub-query results be independent of outer-queries? I understand the optimization and why it is useful - in some cases. However, when SET(@variable, value) is in the selectExpression, the order and number of rows SET(...) is applied to, are critical for correct results.
What if the planner looked for the use of SET(...) in sub-queries before moving a WHERE clause down, and skip the optimization if a SET is used?
Hi,
Shouldn't sub-query results be independent of outer-queries? I understand the optimization and why it is useful - in some cases. However, when SET(@variable, value) is in the selectExpression, the order and number of rows SET(...) is applied to, are critical for correct results.
It depends on what you consider a 'correct' result. I agree it might be confusing if not all rows are read, but disabling optimizations depending on whether such features are used also seems to be wrong.
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
That looks like a bug.
Could you produce a reduced test-case?
This should be fixed in the trunk now, see issue 387: WHERE condition
getting pushed into sub-query with LIMIT.
Regards,
Thomas