-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
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
- More responsive indexer status
Admin panel shows actual progress instead of freezing for minutes & sometime for hours.
- Less DB locking and faster concurrency
Frequent state updates reduce long-running locks.
- Improved fault tolerance
If the process stops after N batches, next run resumes from version_id N.
- 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
Labels
Type
Projects
Status