Merge pull request #4769 from Ruxton/feature/faster_stream_queries
Updating queries for the stream to be faster
This commit is contained in:
commit
4a3869cda8
4 changed files with 8 additions and 5 deletions
|
|
@ -6,6 +6,7 @@
|
|||
* Style improvements for SPV, use original author's avatar for reshares [#4754](https://github.com/diaspora/diaspora/issue/4754)
|
||||
* Update image branding to the new decided standard [#4702](https://github.com/diaspora/diaspora/pull/4702)
|
||||
* Consistent naming of conversations and messages [#4756](https://github.com/diaspora/diaspora/pull/4756)
|
||||
* Improve stream generation time [#4769](https://github.com/diaspora/diaspora/pull/4769)
|
||||
|
||||
|
||||
## Bug fixes
|
||||
|
|
|
|||
|
|
@ -68,10 +68,8 @@ module User::Querying
|
|||
end
|
||||
|
||||
def construct_public_followings_sql(opts)
|
||||
aspects = Aspect.where(:id => opts[:by_members_of])
|
||||
person_ids = Person.connection.select_values(people_in_aspects(aspects).select("people.id").to_sql)
|
||||
|
||||
query = opts[:klass].where(:author_id => person_ids, :public => true, :pending => false)
|
||||
Rails.logger.debug("[EVIL-QUERY] user.construct_public_followings_sql")
|
||||
query = opts[:klass].where(:author_id => Person.in_aspects(opts[:by_members_of]).select("people.id"), :public => true, :pending => false)
|
||||
|
||||
unless(opts[:klass] == Photo)
|
||||
query = query.where(:type => opts[:type])
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ Diaspora::Application.configure do
|
|||
|
||||
# Log the query plan for queries taking more than this (works
|
||||
# with SQLite, MySQL, and PostgreSQL)
|
||||
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||
|
||||
# Do not compress assets
|
||||
config.assets.compress = false
|
||||
|
|
|
|||
|
|
@ -51,20 +51,24 @@ module EvilQuery
|
|||
end
|
||||
|
||||
def make_relation!
|
||||
Rails.logger.debug("[EVIL-QUERY] make_relation!")
|
||||
post_ids = aspects_post_ids! + ids!(followed_tags_posts!) + ids!(mentioned_posts)
|
||||
post_ids += ids!(community_spotlight_posts!) if @include_spotlight
|
||||
Post.where(:id => post_ids)
|
||||
end
|
||||
|
||||
def aspects_post_ids!
|
||||
Rails.logger.debug("[EVIL-QUERY] aspect_post_ids!")
|
||||
@user.visible_shareable_ids(Post, :limit => 15, :order => "#{@order} DESC", :max_time => @max_time, :all_aspects? => true, :by_members_of => @user.aspect_ids)
|
||||
end
|
||||
|
||||
def followed_tags_posts!
|
||||
Rails.logger.debug("[EVIL-QUERY] followed_tags_posts!")
|
||||
StatusMessage.public_tag_stream(@user.followed_tag_ids)
|
||||
end
|
||||
|
||||
def mentioned_posts
|
||||
Rails.logger.debug("[EVIL-QUERY] mentioned_posts")
|
||||
StatusMessage.where_person_is_mentioned(@user.person)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue