magento2
magento2 copied to clipboard
Performance | Redundant Review Rating Info loading
I have found redundant data loading in \Magento\Review\Model\ResourceModel\Rating\Option\Vote\Collection::addRatingInfo
https://github.com/magento/magento2/blob/a88f1ccb4446e5123872cf6c7813147f3638402c/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Vote/Collection.php#L151C1-L152C1
Problem
Let's take \Magento\Review\Model\ResourceModel\Review\Collection::addRateVotes
as a reference
It loads Rate Votes in that way:
$votesCollection = $this->_voteFactory->create()->getResourceCollection()->setReviewFilter(
$item->getId()
)->setStoreFilter(
$this->_storeManager->getStore()->getId()
)->addRatingInfo(
$this->_storeManager->getStore()->getId()
)->load();
In this case data is loaded twice.
- First time in the
Model/ResourceModel/Rating/Option/Vote/Collection.php:151
duringaddRatingInfo()
call by direct SQL request. (result is not used at all) - Second time during
->load()
call. Yes,load()
method does checkisLoaded()
but it's not true as it was direct SQL query.
Let's assume we have thousands of reviews on the Product Details Page and few votes per review - it will take ages to load. So it's a huge performance degradation problem
Solution
I don't see any reasons to load this select directly. So I propose to remove it at all. Prepared PR: https://github.com/magento/magento2/pull/37939
Hi @VladyslavSikailo. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
-
@magento give me 2.4-develop instance
- upcoming 2.4.x release - For more details, review the Magento Contributor Assistant documentation.
- Add a comment to assign the issue:
@magento I am working on this
- To learn more about issue processing workflow, refer to the Code Contributions.
Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
- [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! - [ ] 5. Add label
Issue: Confirmed
once verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @VladyslavSikailo,
Thanks for the report and collaboration!
We have looked into the codebase in order to reproduce the issue and it seems the issue has been reproducible by looking into the code only.
The below function call is not in use:
https://github.com/magento/magento2/blob/7f35b87f8c310dca62b794547d5e5fde5744c120/app/code/Magento/Review/Model/ResourceModel/Rating/Option/Vote/Collection.php#L151
Whereas the fetchAll
method has been returning an array, which is handling the above:
https://github.com/magento/magento2/blob/7f35b87f8c310dca62b794547d5e5fde5744c120/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php#L534-L544
Hence confirming the issue.
Thanks
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-9443 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Thanks for the quick confirmation! Let's process the PR in a same quick way - https://github.com/magento/magento2/pull/37939 😊