diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php
index ee5e918e5df49569d9e52d84a2506dffc8f0248c..81ac21334452cb9d02c2f174e0dae11acefc8932 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();