-
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 catalogrule_product
index even when no catalog rule exists
#34784
Comments
Hi @dudzio12. 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. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
protected function doReindexByIds($ids)
{
$this->cleanProductIndex($ids);
/** @var Rule[] $activeRules */
$activeRules = $this->getActiveRules()->getItems();
foreach ($activeRules as $rule) {
$rule->setProductsFilter($ids);
$this->reindexRuleProduct->execute($rule, $this->batchCount);
}
foreach ($ids as $productId) {
$this->cleanProductPriceIndex([$productId]);
## I've added `if` statement as seen below and there is no need to reindex prices
## if only above cleaning cleans it correctly and no activeRule exists.
## That only sppeds up indexation process more that 10 times
if (count($activeRules) > 0) {
$this->reindexRuleProductPrice->execute($this->batchCount, $productId);
}
}
$this->reindexRuleGroupWebsite->execute();
} |
I'll prepare PR and run some tests with that change implemented. It won't fix non optimal index, but will lock some unnecessary code execution. |
Hi @engcom-Hotel. Thank you for working on this issue.
|
Fixed by #34785 |
The performance of this indexer appears to be incredibly slow, as it reindexes products one by one, instead of in batches. The select builder used is here - magento2/app/code/Magento/CatalogRule/Model/Indexer/RuleProductsSelectBuilder.php Lines 81 to 109 in 0a834cc
A single product id is passed in, and used to restrict the query to that product, but the query would still work if multiple products were passed in and an Similarly, the place that calls and then uses the query built by magento2/app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProductPrice.php Lines 88 to 112 in 0a834cc
This creates a key value using the product id coming from the data the query returns, so it too would still work with multiple products. Maybe I'm missing something here, but I think that changing these functions to take in an array of product ids instead of a single one (and then batching appropriately in |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-10911 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue. |
On a Magento 2.4.3 instance:
Preconditions (*)
Steps to reproduce (*)
catalogrule_product_cl
table.indexer_update_all_views
CRON job.Expected result (*)
Actual result (*)
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: