Skip to content
Snippets Groups Projects
Commit c3ef5d54 authored by alpaca-tc's avatar alpaca-tc Committed by Eugen Rochko
Browse files

Add `account_id DESC` to optimize PrecomputeFeedService (#2967)

parent 57a3d71c
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,8 @@ class PrecomputeFeedService < BaseService
# @param [Account] account
def call(_, account)
redis.pipelined do
Status.as_home_timeline(account).limit(FeedManager::MAX_ITEMS / 4).each do |status|
# NOTE: Added `id desc, account_id desc` to `ORDER BY` section to optimize query.
Status.as_home_timeline(account).order(account_id: :desc).limit(FeedManager::MAX_ITEMS / 4).each do |status|
next if status.direct_visibility? || FeedManager.instance.filter?(:home, status, account.id)
redis.zadd(FeedManager.instance.key(:home, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment