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:
authormattab <matthieu.aubry@gmail.com>2014-03-12 12:24:24 +0400
committermattab <matthieu.aubry@gmail.com>2014-03-12 12:24:24 +0400
commit3d3f3c0d9c79f75e05f7683197e53ac01064e3c6 (patch)
treec7f8e0202636ea920b42de2f4623999c6a394320 /core/Archive.php
parentdd9ec8712f10024cd4536ec9f15f98002980ea8d (diff)
Fixes #4768 Implement performance improvement for period=range: do not archive sub-tables (only the parent table).
The sub-tables will be archived only when idSubtable is found, or flat=1, or expanded=1
Diffstat (limited to 'core/Archive.php')
-rw-r--r--core/Archive.php32
1 files changed, 23 insertions, 9 deletions
diff --git a/core/Archive.php b/core/Archive.php
index db1ca62ded..3f13396599 100644
--- a/core/Archive.php
+++ b/core/Archive.php
@@ -192,9 +192,10 @@ class Archive
* or date range (ie, 'YYYY-MM-DD,YYYY-MM-DD').
* @param bool|false|string $segment Segment definition or false if no segment should be used. {@link Piwik\Segment}
* @param bool|false|string $_restrictSitesToLogin Used only when running as a scheduled task.
+ * @param bool $skipAggregationOfSubTables Whether the archive, when it is processed, should also aggregate all sub-tables
* @return Archive
*/
- public static function build($idSites, $period, $strDate, $segment = false, $_restrictSitesToLogin = false)
+ public static function build($idSites, $period, $strDate, $segment = false, $_restrictSitesToLogin = false, $skipAggregationOfSubTables = false)
{
$websiteIds = Site::getIdSitesFromIdSitesString($idSites, $_restrictSitesToLogin);
@@ -209,7 +210,7 @@ class Archive
$segment = new Segment($segment, $websiteIds);
$idSiteIsAll = $idSites == self::REQUEST_ALL_WEBSITES_FLAG;
$isMultipleDate = Period::isMultiplePeriod($strDate, $period);
- return Archive::factory($segment, $allPeriods, $websiteIds, $idSiteIsAll, $isMultipleDate);
+ return Archive::factory($segment, $allPeriods, $websiteIds, $idSiteIsAll, $isMultipleDate, $skipAggregationOfSubTables);
}
/**
@@ -231,9 +232,11 @@ class Archive
* @param bool $isMultipleDate Whether multiple dates are being queried or not. If true, then
* the result of querying functions will be indexed by period,
* regardless of whether `count($periods) == 1`.
+ * @param bool $skipAggregationOfSubTables Whether the archive should skip aggregation of all sub-tables
+ *
* @return Archive
*/
- public static function factory(Segment $segment, array $periods, array $idSites, $idSiteIsAll = false, $isMultipleDate = false)
+ public static function factory(Segment $segment, array $periods, array $idSites, $idSiteIsAll = false, $isMultipleDate = false, $skipAggregationOfSubTables = false)
{
$forceIndexedBySite = false;
$forceIndexedByDate = false;
@@ -244,7 +247,7 @@ class Archive
$forceIndexedByDate = true;
}
- $params = new Parameters($idSites, $periods, $segment);
+ $params = new Parameters($idSites, $periods, $segment, $skipAggregationOfSubTables);
return new Archive($params, $forceIndexedBySite, $forceIndexedByDate);
}
@@ -432,16 +435,21 @@ class Archive
* @param string $segment @see {@link build()}
* @param bool $expanded If true, loads all subtables. See {@link getDataTableExpanded()}
* @param int|null $idSubtable See {@link getDataTableExpanded()}
+ * @param bool $skipAggregationOfSubTables Whether or not we should skip the aggregation of all sub-tables and only aggregate parent DataTable.
* @param int|null $depth See {@link getDataTableExpanded()}
* @return DataTable|DataTable\Map See {@link getDataTable()} and
* {@link getDataTableExpanded()} for more
* information
*/
public static function getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded,
- $idSubtable = null, $depth = null)
+ $idSubtable = null, $skipAggregationOfSubTables = false, $depth = null)
{
Piwik::checkUserHasViewAccess($idSite);
- $archive = Archive::build($idSite, $period, $date, $segment);
+
+ if($skipAggregationOfSubTables && ($expanded || $idSubtable)) {
+ throw new \Exception("Not expected to skipAggregationOfSubTables when expanded=1 or idSubtable is set.");
+ }
+ $archive = Archive::build($idSite, $period, $date, $segment, $_restrictSitesToLogin = false, $skipAggregationOfSubTables);
if ($idSubtable === false) {
$idSubtable = null;
}
@@ -620,7 +628,7 @@ class Archive
private function cacheArchiveIdsWithoutLaunching($plugins)
{
$idarchivesByReport = ArchiveSelector::getArchiveIds(
- $this->params->getIdSites(), $this->params->getPeriods(), $this->params->getSegment(), $plugins);
+ $this->params->getIdSites(), $this->params->getPeriods(), $this->params->getSegment(), $plugins, $this->params->isSkipAggregationOfSubTables());
// initialize archive ID cache for each report
foreach ($plugins as $plugin) {
@@ -644,7 +652,13 @@ class Archive
*/
private function getDoneStringForPlugin($plugin)
{
- return Rules::getDoneStringFlagFor($this->params->getIdSites(), $this->params->getSegment(), $this->getPeriodLabel(), $plugin);
+ return Rules::getDoneStringFlagFor(
+ $this->params->getIdSites(),
+ $this->params->getSegment(),
+ $this->getPeriodLabel(),
+ $plugin,
+ $this->params->isSkipAggregationOfSubTables()
+ );
}
private function getPeriodLabel()
@@ -776,7 +790,7 @@ class Archive
*/
private function prepareArchive(array $archiveGroups, Site $site, Period $period)
{
- $parameters = new ArchiveProcessor\Parameters($site, $period, $this->params->getSegment());
+ $parameters = new ArchiveProcessor\Parameters($site, $period, $this->params->getSegment(), $this->params->isSkipAggregationOfSubTables());
$archiveLoader = new ArchiveProcessor\Loader($parameters);
$periodString = $period->getRangeString();