PERF: Create a partial regular post_search_data index on large sites.

With the addition of `PostSearchData#private_message`, a partial
index consisting of only search data from regular posts can be created.
The partial index helps to speed up searches on large sites since PG
will not have to do an index scan on the entire search data index which
has shown to be a bottle neck.
This commit is contained in:
Guo Xiang Tan
2020-08-21 16:16:28 +08:00
committed by Alan Guo Xiang Tan
parent f7314f8ab4
commit 40c6d90df3
5 changed files with 126 additions and 17 deletions

View File

@@ -1090,7 +1090,18 @@ class Search
type_filter: opts[:type_filter]
}
min_id = Search.min_post_id
min_id =
if SiteSetting.search_recent_regular_posts_offset_post_id > 0
if %w{all_topics private_message}.include?(opts[:type_filter])
0
else
SiteSetting.search_recent_regular_posts_offset_post_id
end
else
# This is kept around for backwards compatibility.
# TODO: Drop this code path after Discourse 2.7 has been released.
Search.min_post_id
end
if @order == :likes
# likes are a pain to aggregate so skip