PERF: Load topic bookmarks for the user in user_post_bookmarks (#10197)

Instead of loading all of the user bookmarks using all the post IDs in a topic, load all the bookmarks for a user using the topic ID. This eliminates a costly WHERE ID IN query.
This commit is contained in:
Martin Brennan
2020-07-09 15:46:52 +10:00
committed by GitHub
parent d5c56a846a
commit e0713455ca
2 changed files with 14 additions and 1 deletions

View File

@ -435,7 +435,7 @@ class TopicView
end
def user_post_bookmarks
@user_post_bookmarks ||= Bookmark.where(user: @user, post_id: unfiltered_post_ids)
@user_post_bookmarks ||= @topic.bookmarks.where(user: @user)
end
def reviewable_counts