You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Firstly thank you for moving this further. I have few observations, not necessarily fatal errors, might create issues later. For now just one thing:
I was able to update my project from ORM 4 to 5, finally getting my complex query to show correct results. However, the performance drop is significant. Probably due to all the HAVING clauses and ON clause filters. Even when using only simple "any" aggregations that worked in version 4.
SELECT"books".*FROM"books"AS"books"LEFT JOIN"books_x_tags"AS"books_x_tags"ON ("books"."id"="books_x_tags"."book_id")
LEFT JOIN"tags"AS"tags"ON ("books_x_tags"."tag_id"="tags"."id")
WHERE (("books"."id"=3)) OR (("tags"."id"=1))
GROUP BY"books"."id"
ORM 5:
SELECT"books".*FROM"books"AS"books"LEFT JOIN"books_x_tags"AS"books_x_tags_any"ON ("books"."id"="books_x_tags_any"."book_id")
LEFT JOIN"tags"AS"tags_any"ON (("books_x_tags_any"."tag_id"="tags_any"."id") AND"tags_any"."id"=1)
GROUP BY"books"."id", "books"."title"HAVING ((("books"."id"=3)) OR ((COUNT("tags_any"."id") >0)))
This is just a simple query, but in complex queries, the drop is from miliseconds to seconds. The results are correct in both. While I am eager to use new aggregation features, I also need my current queries to work fast without change. I don't know how hard and whether even achievable it would be to optimize this. Not to delay release further, my suggestion is a "legacy mode" that would allow user to use old ORM 4 queries (possibly by overriding AnyAggregator::aggregateExpression to always just return $expression;).
The problem is that we do not know upfront that some other conditions in the expression tree will "always require" HAVING clause.
A similar "problem" was in OR that was outside the specific expression, but it is known when processing, so we could pass it down to let the expression known.
The only sane solution seems to delay processing and do some two-pass processing to realize requirements first and the let the expression produce the correct needed variant.
To provide more smarted SQL rewrites, we need to know if the expression
itself is in AND/OR junction and if other parts of the junction
require a HAVING clause. This is possible only after getting the full
expression tree. Then we collect the actual expressions.
[closes#690]
[closes#686]
Originally posted by @stepapo in #666
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior. It could include:
Expected behavior
A clear and concise description of what you expected to happen.
Versions::
The text was updated successfully, but these errors were encountered: