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:
authorThomas Steur <tsteur@users.noreply.github.com>2022-02-21 06:17:22 +0300
committerGitHub <noreply@github.com>2022-02-21 06:17:22 +0300
commitfe734297e24cea49d1ca3a35b4879e17f92b2921 (patch)
treee4de2a39ba8a3c9d3ae7b887d453c5689d7af5a6
parentf5eda650a61a5c1aaa9073e71bd7b5643bfe52af (diff)
Improve performance of some archiving queries (#18797)
-rw-r--r--core/DataAccess/LogAggregator.php21
1 files changed, 2 insertions, 19 deletions
diff --git a/core/DataAccess/LogAggregator.php b/core/DataAccess/LogAggregator.php
index e283af2691..cada4b1571 100644
--- a/core/DataAccess/LogAggregator.php
+++ b/core/DataAccess/LogAggregator.php
@@ -282,8 +282,7 @@ class LogAggregator
if (defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE) {
$engine = 'ENGINE=MEMORY';
}
- $tempTableIdVisitColumn = 'idvisit BIGINT(10) UNSIGNED NOT NULL';
- $createTableSql = 'CREATE TEMPORARY TABLE ' . $table . ' (' . $tempTableIdVisitColumn . ') ' . $engine;
+ $createTableSql = 'CREATE TEMPORARY TABLE ' . $table . ' (idvisit BIGINT(10) UNSIGNED NOT NULL, PRIMARY KEY (`idvisit`)) ' . $engine;
// we do not insert the data right away using create temporary table ... select ...
// to avoid metadata lock see eg https://www.percona.com/blog/2018/01/10/why-avoid-create-table-as-select-statement/
@@ -293,23 +292,7 @@ class LogAggregator
} catch (\Exception $e) {
if ($readerDb->isErrNo($e, \Piwik\Updater\Migration\Db::ERROR_CODE_TABLE_EXISTS)) {
return;
- } elseif ($readerDb->isErrNo($e, \Piwik\Updater\Migration\Db::ERROR_CODE_REQUIRES_PRIMARY_KEY)
- || $readerDb->isErrNo($e, \Piwik\Updater\Migration\Db::ERROR_CODE_UNABLE_CREATE_TABLE_WITHOUT_PRIMARY_KEY
- || stripos($e->getMessage(), 'requires a primary key') !== false
- || stripos($e->getMessage(), 'table without a primary key') !== false)
- ) {
- $createTableSql = str_replace($tempTableIdVisitColumn, $tempTableIdVisitColumn . ', PRIMARY KEY (`idvisit`)', $createTableSql);
-
- try {
- $readerDb->query($createTableSql);
- } catch (\Exception $e) {
- if ($readerDb->isErrNo($e, \Piwik\Updater\Migration\Db::ERROR_CODE_TABLE_EXISTS)) {
- return;
- } else {
- throw $e;
- }
- }
- } else {
+ } else {
throw $e;
}
}