-
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
Very slow performance for \Magento\Catalog\Api\CategoryLinkRepositoryInterface::save #37739
Comments
Hi @ioweb-gr. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
I would like to add to this that the whole problem is basically the way you are handling URL rewrites in the system. This system is proving too resource intensive to maintain the rewrites and I think it should be rewritten from scratch. Especially the setting to append the product url to the category url path seems to be the main culprit. Since the paths to a category are pretty much static for all products in the category I don't understand why the database table itself needs to maintain a reference to all product paths including the category path when you can just fetch the path for the category and render it. |
You might take a look at my PR #34226 I suggested replacement of repo for simple insert on duplicate, migth fix some performance |
I don't see how it relates. As long as you trigger the category save whether via repository or else how it will still invoke the same observers and plugins and will follow the same path of rebuilding all the url rewrites for the products in the category including all the position recalculations. It doesn't seem to solve the performance issue mentioned here. Could you shed some light as to what it affects in relation to this issue ? |
Is there a workaround for this issue? We have a store with over 500,000 products and 10,000 categories. We recently revamped the whole category tree and we have to move products around but each single update takes ages so it’ll take months to apply all the changes. |
We were in the same predicament @bfontaine but no one from Adobe has taken interest in this :( You can try manually creating and saving the links via the repository directly in the table. It will break some URLs but a tool for regenerating URL rewrites can help you fix it |
Hi @engcom-Hotel. Thank you for working on this issue.
|
@engcom-Hotel do you think you could take another look at this to see if we can find a workaround for this with the core developers? Surely there must be a way to fix this slowness :( |
The only solution I found for this very annoying issue was to temporarily set all indices to "Update on schedule". After I'm done re-assigning products to categories, I re-index all indices and then set their update rule to whatever it was before. |
We're permanently on schedule mode. It doesn't solve the slowness as url rewrites and positions are still rebuilt every single time leading to huge delays and timeouts |
Hello @ioweb-gr, Thanks for the report and collaboration! We have tried to reproduce the issue in the latest 2.4-develop branch, but the issue is not reproducible for us. In our instance, we have almost 4 Lakhs records with 700+ categories. Please refer to the below screenshot for reference: And below is the screenshot of the consumer processing the messages: For us, the updation is happening in milliseconds. Please refer to the below module for reference: https://github.com/engcom-Hotel/magento2/tree/issue37739/app/code/Magz/Categoryproductassign Let us know if we missed anything. Thanks |
We plan to upgrade the website on end of August so we can try it on latest version as well. Maybe the issue has been fixed with latest version but I can't confirm just yet. I'll get back to you once I can retry it. |
Hello @ioweb-gr, Have you got a chance to upgrade your website? Is the issue is still reproducible in the upgraded website? Thanks |
Hi unfortunately we got stalled on the upgrade by the SameSite issue we're facing #38889 . I have this issue in mind as it's a very important task for us. |
Yes unfortunately we're really blocked there. As it's crucial to accept payments by credit card properly in a Greek bank that issue must be solved before we upgrade |
Preconditions and environment
Steps to reproduce
You will get a result like this
As you can see it processed like 30 products in > 15 minutes
The main issue here is that the function
Will actually resave the whole category every time you assign a product to it including all the product positions and everything.
In my case as you can see this is triggering observers for rewriting the urls again and it's causing the delay.
Obviously this speed is not acceptable in terms of performance rendering the code unusable.
In our use case we have to manually handle more than 50k messages / day because when products change their price we need to refresh specific categories with them by deleting or adding them to the category.
Moreover by the time these messages are processed more will be added infinitely in a never ending loop of unfinished message processing.
Sample message handler
Expected result
Assignment is really fast.
Actual result
Assignment is unexpectedly really slow.
Additional information
I've opened that back in 2021 and it was dismissed and closed because I wasn't using MessageQueues. Well here we are in 2023 with messageQueues and the underlying problem is still there. Is there any proposed alternative?
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: