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

@ -543,27 +543,24 @@ describe Search do
])
end
it "allows the configuration of search to prefer recent posts" do
SiteSetting.search_prefer_recent_posts = true
SiteSetting.search_recent_posts_size = 1
post = Fabricate(:post, topic: topic, raw: "this is a play post")
it "is able to search with an offset when configured" do
post_1 = Fabricate(:post, raw: "this is a play post")
SiteSetting.search_recent_regular_posts_offset_post_id = post_1.id + 1
results = Search.execute('play post')
expect(results.posts).to eq([post_1])
post_2 = Fabricate(:post, raw: "this is another play post")
SiteSetting.search_recent_regular_posts_offset_post_id = post_2.id
results = Search.execute('play post')
expect(results.posts.map(&:id)).to eq([
post.id
post_2.id,
post_1.id
])
post2 = Fabricate(:post, raw: "this is a play post")
results = Search.execute('play post')
expect(results.posts.map(&:id)).to eq([
post2.id,
post.id
])
ensure
Discourse.cache.clear
end
it 'allows staff to search for whispers' do