Skip to content

Potential Indexer Performance issue for large catalogs - Locking Entire CL table to identity the latest version to be processed #40331

@senthilengg

Description

@senthilengg

Summary

Retrieving the last id with Order By version_id DESC may cause performance issues when the *_cl table piled up with lot of rows and quietly possible for stores with large catalogs

$select = $this->connection->select()->from($changelogTableName)->order('version_id DESC')->limit(1);

The performance degrade can be moderate to severe based on the number of rows present in cl table.

Examples

Insert few hundred thousand to million rows in CL table and run the query ever minute

Order BY DESC with Limit as per Mysql will be slow

Proposed solution

Since its always run in batches the version id can be manipulated easily

$batchSize = isset($this->changelogBatchSize[$this->getChangelog()->getViewId()])

$currentVersionId = $lastVersionId + $batchSize;

Above math can help avoid locking the entire table and the indexer will get updated in a responsive fashion than waiting for the entire rows to complete.

If 100,000 rows in CL then currently indexer status will not get updated until 100K complete in 20 batches assuming per batch 5000 but with the above proposed change it will get update for every batch.

Benefits

  1. More responsive indexer status

Admin panel shows actual progress instead of freezing for minutes & sometime for hours.

  1. Less DB locking and faster concurrency

Frequent state updates reduce long-running locks.

  1. Improved fault tolerance

If the process stops after N batches, next run resumes from version_id N.

  1. Better observability and diagnosability

Logs and monitoring tools can see actual batch progression.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: ready for confirmationReported on 2.4.xIndicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Ready for Confirmation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions