From d3e63bbac04da20abf9897f962dac10ee7716a58 Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Wed, 1 Jul 2020 17:11:04 +0300 Subject: [PATCH] [CORE] Avoid the old "reply" relation in inboxnoticestream All verbs for not visible notices are filtered out, so this should not break the timeline. Additionally, filter by profile outside of the derived relation as that shows better performance in PostgreSQL and MariaDB both. --- lib/notices/inboxnoticestream.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/notices/inboxnoticestream.php b/lib/notices/inboxnoticestream.php index de621fd3f5..8eb03aeb4a 100644 --- a/lib/notices/inboxnoticestream.php +++ b/lib/notices/inboxnoticestream.php @@ -91,26 +91,24 @@ class RawInboxNoticeStream extends NoticeStream $notice->selectAdd('id'); // Reply:: is a table of mentions // Subscription:: is a table of subscriptions (every user is subscribed to themselves) - $notice->_join .= sprintf( - "\n" . <<<'END' + $notice->_join .= "\n" . <<<'END' LEFT JOIN ( - SELECT notice.id + SELECT notice.id, subscription.subscriber AS profile_id FROM notice INNER JOIN subscription ON notice.profile_id = subscription.subscribed - WHERE subscription.subscriber = %1$d UNION ALL - SELECT notice_id AS id FROM reply WHERE profile_id = %1$d + SELECT reply.id, notice.profile_id + FROM notice AS reply INNER JOIN notice ON reply.reply_to = notice.id UNION ALL - SELECT notice_id AS id FROM attention WHERE profile_id = %1$d + SELECT notice_id, profile_id FROM attention UNION ALL - SELECT notice_id AS id FROM group_inbox INNER JOIN group_member USING (group_id) - WHERE group_member.profile_id = %1$d + SELECT group_inbox.notice_id, group_member.profile_id + FROM group_inbox INNER JOIN group_member USING (group_id) ) AS t1 USING (id) - END, - $this->target->getID() - ); + END; $notice->whereAdd('t1.id IS NOT NULL'); + $notice->whereAdd('t1.profile_id = ' . $this->target->getID()); $notice->whereAdd(sprintf( "notice.created > TIMESTAMP '%s'",