Open martin-cod opened 1 month ago
Hi @martin-cod. 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@magento I am working on this
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.
Summary
When working with product collections I found out that getting attribute values is very slow because of using method
\Magento\Eav\Model\Entity\Attribute\Source\Table::getSpecificOptions
. This method is not optimized to work with product collections because it loads data from Database every time attribute value is requested. Taking in mind that\Magento\Eav\Model\Entity\Attribute\Source\Table
is a default source model for any attribute which has nosource_model
defined ineav_attribute
table it brings a siriouse performance degradation. For example, when working with attribute of textfrontend_input
type it usesgetSpecificOptions()
method which returns empty response every time.To get attribute value there 2 possible loading stacks.
Stack 1. Performance degradation is detected for only attributes of select, multiselect
frontend_input
typeStack 2. Performance degradation is detected for all attribute regardless of
frontend_input
typeExamples
See Summary section with explanations
Proposed solution
Use
\Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions
call ingetSpecificOptions
method, so it will minimize the number of SQL queries to 1 per attribute per product collection because option values ingetAllOptions
method are cachedRelease note
No response
Triage and priority