[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.
This commit is contained in:
parent
819ece93aa
commit
d3e63bbac0
|
@ -91,26 +91,24 @@ class RawInboxNoticeStream extends NoticeStream
|
||||||
$notice->selectAdd('id');
|
$notice->selectAdd('id');
|
||||||
// Reply:: is a table of mentions
|
// Reply:: is a table of mentions
|
||||||
// Subscription:: is a table of subscriptions (every user is subscribed to themselves)
|
// Subscription:: is a table of subscriptions (every user is subscribed to themselves)
|
||||||
$notice->_join .= sprintf(
|
$notice->_join .= "\n" . <<<'END'
|
||||||
"\n" . <<<'END'
|
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT notice.id
|
SELECT notice.id, subscription.subscriber AS profile_id
|
||||||
FROM notice INNER JOIN subscription
|
FROM notice INNER JOIN subscription
|
||||||
ON notice.profile_id = subscription.subscribed
|
ON notice.profile_id = subscription.subscribed
|
||||||
WHERE subscription.subscriber = %1$d
|
|
||||||
UNION ALL
|
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
|
UNION ALL
|
||||||
SELECT notice_id AS id FROM attention WHERE profile_id = %1$d
|
SELECT notice_id, profile_id FROM attention
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT notice_id AS id FROM group_inbox INNER JOIN group_member USING (group_id)
|
SELECT group_inbox.notice_id, group_member.profile_id
|
||||||
WHERE group_member.profile_id = %1$d
|
FROM group_inbox INNER JOIN group_member USING (group_id)
|
||||||
) AS t1 USING (id)
|
) AS t1 USING (id)
|
||||||
END,
|
END;
|
||||||
$this->target->getID()
|
|
||||||
);
|
|
||||||
|
|
||||||
$notice->whereAdd('t1.id IS NOT NULL');
|
$notice->whereAdd('t1.id IS NOT NULL');
|
||||||
|
$notice->whereAdd('t1.profile_id = ' . $this->target->getID());
|
||||||
|
|
||||||
$notice->whereAdd(sprintf(
|
$notice->whereAdd(sprintf(
|
||||||
"notice.created > TIMESTAMP '%s'",
|
"notice.created > TIMESTAMP '%s'",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user