Horrible performance in CountOutputWalker query #9934
Unanswered
Yolo-plop
asked this question in
Support Questions
Replies: 1 comment 1 reply
-
Can you provide a PR with the changes you would suggest? But please note that we do not officially support Informix, so we cannot merge any code that is specific to that database engine. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am encountering major performance issues with counting result rows using the CountOutputWalker. It seems that my database system (IBM Informix) really doesn't like the Doctrine is writing the query. The original select query has some joins and an order by, the count ends up being something like this:
I have of course removed a lot of the query details because it's not very important here, i'm just selecting a main entity, joining two tables and sorting using one of those two joined table.
This query takes about 150ms. It's crazy high, especially considering it's just the final count and there are lots of queries before that one.
Now, let's remove the order by part. It now takes 70ms. Way, way better. Then let's remove those left joins... it's now 15ms.
And here i am confused. I don't understand why we need those parts of the query here. Why do we do a sort when we are just counting the number of rows? Why do we do left joins as it's not going to limit the total number of the main entity that we are getting? Especially since we are doing a distinct id, so it doesn't matter if the query returns more rows with those joins.
The walk select function of the class contains this piece of code:
Why are we doing this only for sql server?
Am i missing something? Is there a reason for keeping those query parts or do we keep them simply because it's not going to create issues in most database systems?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions