mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 08:16:00 +08:00
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:

committed by
Alan Guo Xiang Tan

parent
f7314f8ab4
commit
40c6d90df3
@ -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
|
||||
|
Reference in New Issue
Block a user