Skip to content
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

[2.2.4][Performance][Listing][CE/EE] Too much product collection loads #15001

Open
IgorVitol opened this issue May 4, 2018 · 10 comments
Open
Labels
Area: Catalog Area: Performance Component: ConfigurableProduct Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@IgorVitol
Copy link
Contributor

Preconditions

  1. Magento 2.2.4 Commerce/Community (same for previous 2.2.x versions, at least tested on 2.2.3)

Steps to reproduce

  1. Install clean Magento 2.2.3+ Community/Commerce with sample data
  2. Disable Full Page Cache
  3. Add logging to one of these places (this will support repositories & direct collection calls) :
  • Magento\Catalog\Model\ResourceModel\Product\Collection::_afterLoad()
  • Observe catalog_product_collection_load_after event.

It can be very simple & dirty logging, since our objective here is only to fetch amount of collection loads:

\Magento\Framework\App\ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class)->critical('product collection loaded!');

  1. Visit any listing page which contain configurable products. For example:

/men/tops-men/tees-men.html

Expected result

  1. 30 configurable products on the page = 1 line in the log (1 product collection load).
  2. 15 configurable products on the page = 1 line in the log (1 product collection load).
  3. 9 configurable products on the page = 1 line in the log (1 product collection load).

Actual result

  1. 30 configurable products on the page = 31 lines in the log (31 product collection loads).
  2. 15 configurable products on the page = 16 lines in the log (16 product collection loads).
  3. 9 configurable products on the page = 10 lines in the log (10 product collection loads).

After some investigation, I noted that here is specific method, which loaded child product collection for each separate configurable product on the listing page:

Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProvider::getProducts(ProductInterface $product)
It's code - http://prntscr.com/jdsxq8

This method called from next places:

  1. Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox::hasSpecialPrice
  2. Magento\ConfigurableProduct\Pricing\Price\ConfigurablePriceResolver::resolvePrice
  3. Magento\ConfigurableProduct\Plugin\Catalog\Model\Product\Pricing\Renderer\SalableResolver::afterIsSalable

This looks strange, because first two places seems like already covered by price-index (?), and last one (afterIsSalable) just checks if here is some children available - this definitely can be handled in backend (e.g. we can index such things, disable/move to our/of stock parent if all children are not available, e.t.c.).

In result, here should be only 1 collection call, which will improve general listing page load performance. Especially if you plan to display many products on the page.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label May 4, 2018
@thiagolima-bm
Copy link
Member

@IgorVitol are you going to create a PR for this?

@IgorVitol
Copy link
Contributor Author

@thiagolima-bm Hi! For now I have no free time to make such changes. So I decided at least to report this here.

@ghost ghost self-assigned this Jul 12, 2018
@ghost
Copy link

ghost commented Jul 12, 2018

@IgorVitol, thank you for your report.
We've acknowledged the issue and added to our backlog.

@ghost ghost added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Component: ConfigurableProduct labels Jul 12, 2018
@ghost ghost removed their assignment Jul 12, 2018
@pmclain
Copy link
Contributor

pmclain commented Oct 23, 2018

It looks like this has already been fixed 59c0e31#diff-e737458adb2a6eb7bd565d7bf7d9d91aR47

@RicardsRikmanis
Copy link

RicardsRikmanis commented Mar 12, 2019

Magento\ConfigurableProduct\Plugin\Catalog\Model\Product\Pricing\Renderer\SalableResolver::afterIsSalable has been fixed.

Magento\ConfigurableProduct\Pricing\Price\ConfigurablePriceResolver::resolvePrice and Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox::hasSpecialPrice still calls LowestPriceOptionsProvider which results in excessive product collection calls in categories that contain configurable products.

It would make sense to to resolve the pricing on in the collection itself since it already contains simple products.

@IgorVitol
Copy link
Contributor Author

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @IgorVitol. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @IgorVitol, here is your Magento instance.
Admin access: https://i-15001-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@ghost ghost removed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Oct 20, 2020
@magento-engcom-team magento-engcom-team added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Nov 30, 2020
@engcom-Hotel engcom-Hotel added Area: Catalog Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 25, 2021
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.magento.com/browse/AC-1024 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Aug 25, 2021

✅ 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.

@ihor-sviziev ihor-sviziev added the Area: Perf/Frontend All tickets related with improving frontend performance. label Nov 24, 2021
@ihor-sviziev ihor-sviziev added Area: Performance and removed Area: Perf/Frontend All tickets related with improving frontend performance. labels Dec 24, 2021
@engcom-Hotel engcom-Hotel moved this to Ready for Development in High Priority Backlog Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Catalog Area: Performance Component: ConfigurableProduct Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Status: Ready for Development
Development

No branches or pull requests

9 participants