mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
PERF: improve offset discovery query
This commit is contained in:
parent
80e2fa05be
commit
8a792508e9
1 changed files with 7 additions and 3 deletions
|
@ -131,10 +131,14 @@ class Search
|
|||
def self.min_post_id_no_cache
|
||||
return 0 unless SiteSetting.search_prefer_recent_posts?
|
||||
|
||||
offset = Post.unscoped.count - SiteSetting.search_recent_posts_size
|
||||
return 0 if offset <= 0
|
||||
|
||||
Post.unscoped.order(:id).offset(offset).limit(1).pluck(:id)[0]
|
||||
offset, has_more = Post.unscoped
|
||||
.order('id desc')
|
||||
.offset(SiteSetting.search_recent_posts_size-1)
|
||||
.limit(2)
|
||||
.pluck(:id)
|
||||
|
||||
has_more ? offset : 0
|
||||
end
|
||||
|
||||
def self.min_post_id(opts=nil)
|
||||
|
|
Loading…
Reference in a new issue