mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 10:01:11 +08:00
DEV: Prefer nested queries (#23464)
Some sites have a large number of categories and fetching the category IDs or category topic IDs just to build another query can take a long time or resources (i.e. memory).
This commit is contained in:
@ -931,7 +931,7 @@ class ApplicationController < ActionController::Base
|
||||
Discourse
|
||||
.cache
|
||||
.fetch(key, expires_in: 10.minutes) do
|
||||
category_topic_ids = Category.pluck(:topic_id).compact
|
||||
category_topic_ids = Category.select(:topic_id).where.not(topic_id: nil)
|
||||
@top_viewed =
|
||||
TopicQuery
|
||||
.new(nil, except_topic_ids: category_topic_ids)
|
||||
|
Reference in New Issue
Block a user