-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data providers perform unnecessary COUNT queries that negatively affect performance #20213
Comments
Usually User::getDb()->queryCache = new \yii\caching\ArrayCache(); |
@lav45 getTotalCount() is being called multiple times during GridView rendering. It's normal. However, due to the bug, $this->_totalCount is never initialized, so it's always null. |
@lav45, it's regression. In 2.0.49, the caching logic is correct. $this->_totalCount is initialized when it's null
|
This caching method breaks this test |
@lav45 This is a new test, which is not even released and changes behavior that existed in framework since the beginning (and probably breaks BC in some cases) - I think it is fine to drop it if it creates any problems. In general problems started with #20070 (preceded by #20007) and each attempt to fix them created even more problems and regressions. I suggest to revert all changes to state before #20070 or #20007 and start again from there. Messing with pagination and data provider cache looks like a dead end to me. |
@lav45 You added this test, and I think it's wrong because it's artificial. What would a real-life situation be when you need to change the provider's query after a pagination call? 2.0.49 can't pass this test also. It breaks BC. It ruins performance. I support the idea of reverting all your changes. |
What is needed to solve the immediate issue here? Can we revert all the mensioned changes so we can release 2.0.50.1? 2.0.50 is now very much broken in this regard and has been for a few weeks. It would be good to solve the release first, and then re-address the solution for this ticket. If I understand correctly that means the following PR's should be reverted: |
@marcovtwout I'm afraid the only immediate solution is to downgrade to 2.0.49.4. |
@terabytesoftw is on rolling back the changes. |
This surely breaks even more stuff, totalcount is cached at runtime forever. |
I think it should be added. |
I also think that testing needs to be improved. |
I think we should also revert this PR: #20002 @rob006 @samdark @sleptor |
Alright. |
All changes were reverted: Thks. |
@terabytesoftw It does not look like full revert, there are still changes comparing to 2.0.49: yii2/framework/data/ActiveDataProvider.php Lines 164 to 176 in 54702a8
vs yii2/framework/data/ActiveDataProvider.php Lines 162 to 169 in 64a1393
|
@rob006 Fixed, thks. |
Hi guys, sorry for being late to the party :) JFTR, we were also affected by this bug. |
What steps will reproduce the problem?
Check the debug panel on any page containing GridView.
What is the expected result?
Single COUNT query
What do you get instead?
Multiple identical COUNT queries
Additional info
The problem is in this function:
https://github.com/yiisoft/yii2/blob/master/framework/data/BaseDataProvider.php#L165 and related to the changes made in this commit lav45@bcc499b
It is expected to implement caching, but due to a bug/typo it always calls $this->prepareTotalCount().
The correct code has to be the following:
The text was updated successfully, but these errors were encountered: