Merge pull request #8895 from annando/performance
Database performance updates
This commit is contained in:
commit
1a385153f8
11
mod/ping.php
11
mod/ping.php
|
@ -136,13 +136,9 @@ function ping_init(App $a)
|
||||||
|
|
||||||
$notifs = ping_get_notifications(local_user());
|
$notifs = ping_get_notifications(local_user());
|
||||||
|
|
||||||
$condition = ["`unseen` AND `uid` = ? AND `contact-id` != ? AND (`vid` != ? OR `vid` IS NULL)",
|
$condition = ["`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
|
||||||
local_user(), local_user(), Verb::getID(Activity::FOLLOW)];
|
local_user(), Verb::getID(Activity::FOLLOW)];
|
||||||
$fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
|
$items = Item::selectForUser(local_user(), ['wall', 'uid', 'uri-id'], $condition);
|
||||||
'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);
|
|
||||||
|
|
||||||
if (DBA::isResult($items)) {
|
if (DBA::isResult($items)) {
|
||||||
$items_unseen = Item::inArray($items);
|
$items_unseen = Item::inArray($items);
|
||||||
$arr = ['items' => $items_unseen];
|
$arr = ['items' => $items_unseen];
|
||||||
|
@ -156,6 +152,7 @@ function ping_init(App $a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DBA::close($items);
|
||||||
|
|
||||||
if ($network_count) {
|
if ($network_count) {
|
||||||
// Find out how unseen network posts are spread across groups
|
// Find out how unseen network posts are spread across groups
|
||||||
|
|
|
@ -343,7 +343,7 @@ class Database
|
||||||
$row['key'] . "\t" . $row['rows'] . "\t" . $row['Extra'] . "\t" .
|
$row['key'] . "\t" . $row['rows'] . "\t" . $row['Extra'] . "\t" .
|
||||||
basename($backtrace[1]["file"]) . "\t" .
|
basename($backtrace[1]["file"]) . "\t" .
|
||||||
$backtrace[1]["line"] . "\t" . $backtrace[2]["function"] . "\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" .
|
@file_put_contents($this->configCache->get('system', 'db_log'), DateTimeFormat::utcNow() . "\t" . $duration . "\t" .
|
||||||
basename($backtrace[1]["file"]) . "\t" .
|
basename($backtrace[1]["file"]) . "\t" .
|
||||||
$backtrace[1]["line"] . "\t" . $backtrace[2]["function"] . "\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;
|
return $retval;
|
||||||
|
|
|
@ -2093,7 +2093,7 @@ class Item
|
||||||
DBA::close($contacts);
|
DBA::close($contacts);
|
||||||
|
|
||||||
if (!empty($owner['alias'])) {
|
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);
|
$contacts = DBA::select('contact', ['uid'], $condition);
|
||||||
while ($contact = DBA::fetch($contacts)) {
|
while ($contact = DBA::fetch($contacts)) {
|
||||||
if ($contact['uid'] == 0) {
|
if ($contact['uid'] == 0) {
|
||||||
|
|
|
@ -160,7 +160,6 @@ class Cron
|
||||||
$condition = ["`network` IN (?, ?, ?, ?) AND `uid` = ? AND NOT `self` AND `last-update` < ?",
|
$condition = ["`network` IN (?, ?, ?, ?) AND `uid` = ? AND NOT `self` AND `last-update` < ?",
|
||||||
Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, 0, $last_updated];
|
Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, 0, $last_updated];
|
||||||
|
|
||||||
$total = DBA::count('contact', $condition);
|
|
||||||
$oldest_date = '';
|
$oldest_date = '';
|
||||||
$oldest_id = '';
|
$oldest_id = '';
|
||||||
$contacts = DBA::select('contact', ['id', 'last-update'], $condition, ['limit' => 100, 'order' => ['last-update']]);
|
$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');
|
Worker::add(PRIORITY_LOW, "UpdateContact", $contact['id'], 'force');
|
||||||
++$count;
|
++$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);
|
DBA::close($contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1355);
|
define('DB_UPDATE_VERSION', 1356);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -198,6 +198,7 @@ return [
|
||||||
"attag_uid" => ["attag(32)", "uid"],
|
"attag_uid" => ["attag(32)", "uid"],
|
||||||
"dfrn-id" => ["dfrn-id(64)"],
|
"dfrn-id" => ["dfrn-id(64)"],
|
||||||
"issued-id" => ["issued-id(64)"],
|
"issued-id" => ["issued-id(64)"],
|
||||||
|
"network_uid_lastupdate" => ["network", "uid", "last-update"],
|
||||||
"gsid" => ["gsid"]
|
"gsid" => ["gsid"]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
@ -319,6 +320,7 @@ return [
|
||||||
"addr" => ["addr(32)"],
|
"addr" => ["addr(32)"],
|
||||||
"alias" => ["alias(190)"],
|
"alias" => ["alias(190)"],
|
||||||
"followers" => ["followers(190)"],
|
"followers" => ["followers(190)"],
|
||||||
|
"baseurl" => ["baseurl(190)"],
|
||||||
"gsid" => ["gsid"]
|
"gsid" => ["gsid"]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue