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
path: root/core
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2019-07-05 16:35:07 +0300
committerGitHub <noreply@github.com>2019-07-05 16:35:07 +0300
commitaed8c10c30a7eeafba02477f3877cf0c787b0191 (patch)
tree96367c3929e95781cb45cf9ed575ffe090085e10 /core
parent7147fc3e880d033a9f5551634e777e5c7a1467bb (diff)
avoid using group by and select min for tracker actions query to avoid tmp tables refs #14535 (#14584)
Diffstat (limited to 'core')
-rw-r--r--core/Tracker/Model.php34
1 files changed, 28 insertions, 6 deletions
diff --git a/core/Tracker/Model.php b/core/Tracker/Model.php
index 16fc04fd92..b5bb57edaa 100644
--- a/core/Tracker/Model.php
+++ b/core/Tracker/Model.php
@@ -215,8 +215,7 @@ class Model
*/
public function getIdsAction($actionsNameAndType)
{
- $sql = "SELECT MIN(idaction) as idaction, type, name FROM " . Common::prefixTable('log_action')
- . " WHERE";
+ $sql = "SELECT `idaction`, `type`, `name` FROM " . Common::prefixTable('log_action') . " WHERE";
$bind = array();
$i = 0;
@@ -239,16 +238,39 @@ class Model
$i++;
}
- $sql .= " GROUP BY type, hash, name";
-
// Case URL & Title are empty
if (empty($bind)) {
return false;
}
- $actionIds = $this->getDb()->fetchAll($sql, $bind);
+ $rows = $this->getDb()->fetchAll($sql, $bind);
+
+ $actionsPerType = array();
+
+ foreach ($rows as $row) {
+ $name = $row['name'];
+ $type = $row['type'];
+
+ if (!isset($actionsPerType[$type])) {
+ $actionsPerType[$type] = array();
+ }
+
+ if (!isset($actionsPerType[$type][$name])) {
+ $actionsPerType[$type][$name] = $row;
+ } elseif ($row['idaction'] < $actionsPerType[$type][$name]['idaction']) {
+ // keep the lowest idaction for this type, name
+ $actionsPerType[$type][$name] = $row;
+ }
+ }
+
+ $actionsToReturn = array();
+ foreach ($actionsPerType as $type => $actionsPerName) {
+ foreach ($actionsPerName as $actionPerName) {
+ $actionsToReturn[] = $actionPerName;
+ }
+ }
- return $actionIds;
+ return $actionsToReturn;
}
public function updateEcommerceItem($originalIdOrder, $newItem)