Performance fix the analytics_collect_data cron job long run #40463
+4
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (*)
For a fairly large database, the
analytics_collect_datacron job takes too long to execute. For one real example project, it took last time ~36 hours.According to the investigation, the reason for that is the validation of the report definition query. By adding a limit of 0, it turns into a final SQL-query without any limits at all. As a result, there is a loading of all tables data.
The solution is super simple - to add a limit equal to 1 to the validation query
Manual testing scenarios (*)
query(line 55). Unfortunately, thebin/magento dev:query-log:enabledoesn't log such queries.analytics_collect_datacron jobgrep 'Report validation query' var/log/system.logExamples
Before change
There is queries, before the change was applied
After
After the limitation was added
Contribution checklist (*)