mirror of
https://github.com/flarum/framework.git
synced 2025-03-15 00:05:12 +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)
|
||||
{
|
||||
return Discussion::whereIn('id', function ($query) use ($postIds) {
|
||||
$query->select('discussion_id')->from('posts')->whereIn('id', $postIds);
|
||||
})
|
||||
return Discussion::query()
|
||||
->select('discussions.*')
|
||||
->join('posts', 'posts.discussion_id', '=', 'discussions.id')
|
||||
->whereIn('posts.id', $postIds)
|
||||
->groupBy('discussions.id')
|
||||
->whereVisibleTo($actor)
|
||||
->get();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user