Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/ArchiveProcessor.php26
1 files changed, 23 insertions, 3 deletions
diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php
index ee5e918e5d..81ac213344 100644
--- a/core/ArchiveProcessor.php
+++ b/core/ArchiveProcessor.php
@@ -9,6 +9,7 @@
namespace Piwik;
use Exception;
+use Piwik\Archive\DataTableFactory;
use Piwik\ArchiveProcessor\Parameters;
use Piwik\ArchiveProcessor\Rules;
use Piwik\DataAccess\ArchiveWriter;
@@ -352,9 +353,15 @@ class ArchiveProcessor
$self = $this;
$dataTable->filter(function ($table) use ($self, $columnsToRenameAfterAggregation) {
- /** @var \Piwik\Period $period */
- $period = $table->getMetadata('period');
- if (!$period || $period->getLabel() === 'day') {
+ if ($self->areColumnsNotAlreadyRenamed($table)) {
+ /**
+ * This makes archiving and range dates a lot faster. Imagine we archive a week, then we will
+ * rename all columns of each 7 day archives. Afterwards we know the columns will be replaced in a
+ * week archive. When generating month archives, which uses mostly week archives, we do not have
+ * to replace those columns for the week archives again since we can be sure they were already
+ * replaced. Same when aggregating year and range archives. This can save up 10% or more when
+ * aggregating Month, Year and Range archives.
+ */
$self->renameColumnsAfterAggregation($table, $columnsToRenameAfterAggregation);
}
});
@@ -369,6 +376,19 @@ class ArchiveProcessor
return $dataTable;
}
+ /**
+ * Note: public only for use in closure in PHP 5.3.
+ *
+ * @param $table
+ * @return \Piwik\Period
+ */
+ public function areColumnsNotAlreadyRenamed($table)
+ {
+ $period = $table->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX);
+
+ return !$period || $period->getLabel() === 'day';
+ }
+
protected function getOperationForColumns($columns, $defaultOperation)
{
$operationForColumn = array();