mirror of
https://github.com/flarum/framework.git
synced 2025-04-02 23:19:04 +08:00
SQL Performance tuning (#952)
MySQL has problems with executing this subquery efficiently.
This commit is contained in:
parent
68c4dec763
commit
50bbe32175
@ -146,9 +146,11 @@ class PostRepository
|
|||||||
|
|
||||||
protected function getDiscussionsForPosts($postIds, User $actor)
|
protected function getDiscussionsForPosts($postIds, User $actor)
|
||||||
{
|
{
|
||||||
return Discussion::whereIn('id', function ($query) use ($postIds) {
|
return Discussion::query()
|
||||||
$query->select('discussion_id')->from('posts')->whereIn('id', $postIds);
|
->select('discussions.*')
|
||||||
})
|
->join('posts', 'posts.discussion_id', '=', 'discussions.id')
|
||||||
|
->whereIn('posts.id', $postIds)
|
||||||
|
->groupBy('discussions.id')
|
||||||
->whereVisibleTo($actor)
|
->whereVisibleTo($actor)
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user