]> git.mxchange.org Git - friendica.git/commitdiff
Database performance updates
authorMichael Vogel <icarus@dabo.de>
Sat, 18 Jul 2020 15:49:10 +0000 (17:49 +0200)
committerMichael Vogel <icarus@dabo.de>
Sat, 18 Jul 2020 15:49:10 +0000 (17:49 +0200)
mod/ping.php
src/Database/Database.php
src/Model/Item.php
src/Worker/Cron.php
static/dbstructure.config.php

index d1983e8036cb73f6bca5474c5c118ad891b90bc5..4b972369c7021e732b5703c866f03083b812f5d1 100644 (file)
@@ -136,13 +136,9 @@ function ping_init(App $a)
 
                $notifs = ping_get_notifications(local_user());
 
-               $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ? AND (`vid` != ? OR `vid` IS NULL)",
-                       local_user(), local_user(), Verb::getID(Activity::FOLLOW)];
-               $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
-                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall', 'activity'];
-               $params = ['order' => ['received' => true]];
-               $items = Item::selectForUser(local_user(), $fields, $condition, $params);
-
+               $condition = ["`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
+                       local_user(), Verb::getID(Activity::FOLLOW)];
+               $items = Item::selectForUser(local_user(), ['wall'], $condition);
                if (DBA::isResult($items)) {
                        $items_unseen = Item::inArray($items);
                        $arr = ['items' => $items_unseen];
@@ -156,6 +152,7 @@ function ping_init(App $a)
                                }
                        }
                }
+               DBA::close($items);
 
                if ($network_count) {
                        // Find out how unseen network posts are spread across groups
index eaf4900509c50a0b9a0e4626b3249a3811bcb834..5ef481556328cb061d225be9b5f7c4bb551852b0 100644 (file)
@@ -343,7 +343,7 @@ class Database
                                                                                                      $row['key'] . "\t" . $row['rows'] . "\t" . $row['Extra'] . "\t" .
                                                                                                      basename($backtrace[1]["file"]) . "\t" .
                                                                                                      $backtrace[1]["line"] . "\t" . $backtrace[2]["function"] . "\t" .
-                                                                                                     substr($query, 0, 2000) . "\n", FILE_APPEND);
+                                                                                                     substr($query, 0, 4000) . "\n", FILE_APPEND);
                        }
                }
        }
@@ -712,7 +712,7 @@ class Database
                                @file_put_contents($this->configCache->get('system', 'db_log'), DateTimeFormat::utcNow() . "\t" . $duration . "\t" .
                                                                                                basename($backtrace[1]["file"]) . "\t" .
                                                                                                $backtrace[1]["line"] . "\t" . $backtrace[2]["function"] . "\t" .
-                                                                                               substr($this->replaceParameters($sql, $args), 0, 2000) . "\n", FILE_APPEND);
+                                                                                               substr($this->replaceParameters($sql, $args), 0, 4000) . "\n", FILE_APPEND);
                        }
                }
                return $retval;
index 332c734fa5b8db976fe97c92b7a6239af285b4d6..c75286b25ca5d13b7561373f8f48d47587b74788 100644 (file)
@@ -2093,7 +2093,7 @@ class Item
                DBA::close($contacts);
 
                if (!empty($owner['alias'])) {
-                       $condition = ['url' => $owner['alias'], 'rel' => [Contact::SHARING, Contact::FRIEND]];
+                       $condition = ['nurl' => Strings::normaliseLink($owner['alias']), 'rel' => [Contact::SHARING, Contact::FRIEND]];
                        $contacts = DBA::select('contact', ['uid'], $condition);
                        while ($contact = DBA::fetch($contacts)) {
                                if ($contact['uid'] == 0) {
index a47193334ca4081bf6862b07dd244fddf9233044..6749b9648d667b6e5e57f68ac2ea6e039f1f3fc3 100644 (file)
@@ -160,7 +160,6 @@ class Cron
                $condition = ["`network` IN (?, ?, ?, ?) AND `uid` = ? AND NOT `self` AND `last-update` < ?",
                        Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, 0, $last_updated];
 
-               $total = DBA::count('contact', $condition);
                $oldest_date = '';
                $oldest_id = '';
                $contacts = DBA::select('contact', ['id', 'last-update'], $condition, ['limit' => 100, 'order' => ['last-update']]);
@@ -172,7 +171,7 @@ class Cron
                        Worker::add(PRIORITY_LOW, "UpdateContact", $contact['id'], 'force');
                        ++$count;
                }
-               Logger::info('Initiated update for public contacts', ['interval' => $count, 'total' => $total, 'id' => $oldest_id, 'oldest' => $oldest_date]);
+               Logger::info('Initiated update for public contacts', ['interval' => $count, 'id' => $oldest_id, 'oldest' => $oldest_date]);
                DBA::close($contacts);
        }
 
index bab158d036759faba477a9792530e32e37378f67..344a21fc5d326b5b4a354ad84135fe5edd324604 100755 (executable)
@@ -54,7 +54,7 @@
 use Friendica\Database\DBA;
 
 if (!defined('DB_UPDATE_VERSION')) {
-       define('DB_UPDATE_VERSION', 1355);
+       define('DB_UPDATE_VERSION', 1356);
 }
 
 return [
@@ -198,6 +198,7 @@ return [
                        "attag_uid" => ["attag(32)", "uid"],
                        "dfrn-id" => ["dfrn-id(64)"],
                        "issued-id" => ["issued-id(64)"],
+                       "network_uid_lastupdate" => ["network", "uid", "last-update"],
                        "gsid" => ["gsid"]
                ]
        ],
@@ -319,6 +320,7 @@ return [
                        "addr" => ["addr(32)"],
                        "alias" => ["alias(190)"],
                        "followers" => ["followers(190)"],
+                       "baseurl" => ["baseurl(190)"],
                        "gsid" => ["gsid"]
                ]
        ],