Improved indexes, avoiding SQL errors, improving speed

This commit is contained in:
Michael 2021-02-20 20:07:25 +00:00
parent d2360d14ed
commit 92a8a399de
8 changed files with 43 additions and 75 deletions

View file

@ -315,13 +315,13 @@ class Community extends BaseModule
{
if (self::$content == 'local') {
if (!is_null(self::$accountType)) {
$condition = ["`wall` AND `origin` AND `private` = ? AND `owner`.`contact-type` = ?", Item::PUBLIC, self::$accountType];
$condition = ["`wall` AND `origin` AND `private` = ? AND `owner-contact-type` = ?", Item::PUBLIC, self::$accountType];
} else {
$condition = ["`wall` AND `origin` AND `private` = ?", Item::PUBLIC];
}
} elseif (self::$content == 'global') {
if (!is_null(self::$accountType)) {
$condition = ["`uid` = ? AND `private` = ? AND `owner`.`contact-type` = ?", 0, Item::PUBLIC, self::$accountType];
$condition = ["`uid` = ? AND `private` = ? AND `owner-contact-type` = ?", 0, Item::PUBLIC, self::$accountType];
} else {
$condition = ["`uid` = ? AND `private` = ?", 0, Item::PUBLIC];
}

View file

@ -181,9 +181,9 @@ class Status extends BaseProfile
$condition = DBA::mergeConditions($condition, ["((`gravity` = ? AND `wall`) OR
(`gravity` = ? AND `vid` = ? AND `origin` AND `thr-parent-id` IN
(SELECT `uri-id` FROM `post-view` AS `i`
(SELECT `uri-id` FROM `post-view`
WHERE `gravity` = ? AND `network` IN (?, ?, ?, ?) AND `uid` IN (?, ?)
AND `i`.`uri-id` = `thr-parent-id`)))",
AND `uri-id` = `thr-parent-id`)))",
GRAVITY_PARENT, GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), GRAVITY_PARENT,
Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::DIASPORA, Protocol::OSTATUS,
0, $a->profile['uid']]);

View file

@ -81,7 +81,7 @@ class Profile extends BaseModule
}
$items_stmt = DBA::p(
"SELECT DISTINCT(`parent-uri-id`) AS `uri-id`, `created` FROM `post-view`
"SELECT DISTINCT(`parent-uri-id`) AS `uri-id`, MAX(`created`), MAX(`received`) FROM `post-view`
WHERE `uid` = ? AND NOT `contact-blocked` AND NOT `contact-pending`
AND `visible` AND (NOT `deleted` OR `gravity` = ?)
AND `wall` $sql_extra4 $sql_extra