-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Performance - Loading attribute options from DB #36174
Comments
Hi @Nuranto. Thank you for your report.
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:
For more details, review the Magento Contributor Assistant documentation. Add a comment to assign the issue: To learn more about issue processing workflow, refer to the Code Contributions.
🕙 You can find the schedule on the Magento Community Calendar page. 📞 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. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @engcom-November. Thank you for working on this issue.
|
Confirming this issue as execution of getAttributeText() several times would lead to performance issues with high DB loads. |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-6856 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-November. Thank you for verifying the issue. |
@magento I am working on this |
any updates? we found out this problem is related to most of our performance problems. |
Hi, I'm starting a PR here: #39476 We are having this performance issue too on website with many attributes options and products. |
@magento I am working on this |
Hi @anthony-blackbird! 👋 |
@magento add to contributors team |
Hi @anthony-blackbird! 👋 |
@magento I am working on this |
While the PR is processed, I suggest this package I developed, compatible with Magento 2.4.x. It also introduces a cache layer for these specific options loaded. I might add it to my PR if Magento Team is interested too. More details on the readme : https://github.com/blackbird-agency/magento-eav-optimize |
Summary (*)
When using
$product->getAttributeText('some_attribute_using_table_source')
, this is executed :And
getOptionText
get its data from database.The issue is that if we call
getAttributeText()
several times, a call to database will occur every time. I know query cache will help, but this is still DB calls, so DB load (with networks time for each request, etc..) which is not negligible with high loads.Examples (*)
results as
So 2ms for the first request, and then 0.3-0.4ms thanks to query cache. And that's on my local environment, without any network and load involved.
Let's say you're displaying 4 attributes on a product list page, with 50 products per page, that's (assuming each product has different attribute values, so without any query cache) :
50*4*2ms = 400ms
and 200 DB calls.Proposed solution
With a simple cache with class variables, we get this result :
I'm not sure which way is the best for caching. Probably caching the whole table with both backend cache (like redis) and class-cache (class static variable) would be the best way to limit DB calls.
Something like this (pseudo-code just to show the idea) :
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: