Faster archiving by calculating the recursive count only if needed #7468
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.
The method
ArchiveProcessor::aggregateDataTableRecords
counts by default the number of rows recursive. I noticed this takes a lot of time especially on large dataTables: https://github.com/piwik/piwik/blob/2.12.0-b7/core/ArchiveProcessor.php#L220We're calling this method 17 times but it is only actually used once. Therefore I added a parameter to disable it (not enabled by default to stay BC. I failed to find a better solution. Only solution I could think of alternatively would be to add another method that does not count recursive.
In the following example run you can see that it takes 13.5 seconds (with xhprof and only no_builtins flag) which is 15% of the total time to get the rows count recursive. And this is only for 5 records. Those 17 calls easily make 30 records. Meaning we will save a lot of time when generating week, month, year and range archives.
)