modqueue: fix performance regression from including appeals.

* Add index on posts.is_deleted. The modqueue was slow because we the
 appeal condition wasn't constrained to deleted posts, so it degraded to
 a full table scan.

* Avoid extra queries for calculating the page count and disapproval counts.
This commit is contained in:
evazion
2020-08-16 14:27:34 -05:00
parent 16cfdb8321
commit f337902c57
4 changed files with 19 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
class AddDeletedIndexOnPosts < ActiveRecord::Migration[6.0]
def change
add_index :posts, :is_deleted, where: "is_deleted = true"
end
end