404 page had horrible perf, it was using "take" instead of limit.
in such cases EVERY row is materialized and only after the limit is applied. So ... imagine what happens on a forum with 2,000,000 topics
This commit is contained in:
parent
a3128665cf
commit
af467a1675
|
@ -1,5 +1,5 @@
|
||||||
class ExceptionsController < ApplicationController
|
class ExceptionsController < ApplicationController
|
||||||
skip_before_filter :check_xhr
|
skip_before_filter :check_xhr, :preload_json
|
||||||
|
|
||||||
def not_found
|
def not_found
|
||||||
# centralize all rendering of 404 into app controller
|
# centralize all rendering of 404 into app controller
|
||||||
|
|
|
@ -65,12 +65,12 @@ class TopicQuery
|
||||||
"CASE WHEN (topics.pinned_at IS NOT NULL) THEN 0 ELSE 1 END, topics.bumped_at DESC"
|
"CASE WHEN (topics.pinned_at IS NOT NULL) THEN 0 ELSE 1 END, topics.bumped_at DESC"
|
||||||
end
|
end
|
||||||
|
|
||||||
def top_viewed(max)
|
def top_viewed(max = 10)
|
||||||
Topic.listable_topics.visible.secured.order('views desc').take(10)
|
Topic.listable_topics.visible.secured.order('views desc').limit(max)
|
||||||
end
|
end
|
||||||
|
|
||||||
def recent(max)
|
def recent(max = 10)
|
||||||
Topic.listable_topics.visible.secured.order('created_at desc').take(10)
|
Topic.listable_topics.visible.secured.order('created_at desc').limit(max)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue