magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Issue with huge reindex time. Reindex optimization. #26403

Open AndreyChorniy opened 4 years ago

AndreyChorniy commented 4 years ago

Preconditions (*)

  1. Magento version 2.3.2-p2 & 2.4-develop
  2. Above 900K of products
  3. Added customization to Magento\Framework\Mview\View to decrease the count of entities per one indexer iteration to 1000. This is potential should decrease the time for reindex execution

Steps to reproduce (*)

  1. Change prices for 544771 products
  2. Run command php ./bin/magento indexer:status You will see something like these reindexIssue
  3. Run reindex using the command php ./bin/magento cron:run --group=index --bootstrap=standaloneProcessStarted=1
  4. Reindex working about 2 hrs and we get updated 1000 entities during this time.

A lot of time take execution this logic

I have investigated this method and log query:

INSERT INTOcatalogrule_group_website(rule_id,customer_group_id,website_id) SELECT DISTINCTcatalogrule_product.rule_id,catalogrule_product.customer_group_id,catalogrule_product.website_idFROMcatalogrule_productWHERE (1578602213 >= from_time AND ((1578602213 <= to_time AND to_time > 0) OR to_time = 0)) ON DUPLICATE KEY UPDATErule_id= VALUES(rule_id),customer_group_id= VALUES(customer_group_id),website_id= VALUES(website_id)

This query executed about 3000 times per one cron run for update 1000 entities. And each insert take about 2 seconds. So time for 3000 inserts takes about 1,5 hrs.

Expected result (*)

Reindex work faster

Actual result (*)

Reindex working about 2hrs and during this time we have updated only 1000 entities.

I appreciate any ideas here

m2-assistant[bot] commented 4 years ago

Hi @AndreyChorniy. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@AndreyChorniy do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?


m2-assistant[bot] commented 4 years ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @engcom-Hotel Thank you for verifying the issue. Based on the provided information internal tickets MC-30509 were created

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.

github-jira-sync-bot commented 3 years ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-793