A platform for community discussion. Free, open, simple.
PERF: Add index to speed up `User#number_of_flagged_posts`.
Guo Xiang Tanf0f1e878feb6
diff --git a/db/migrate/20190320091323_add_index_post_action_type_id_disagreed_at_on_post_actions.rb b/db/migrate/20190320091323_add_index_post_action_type_id_disagreed_at_on_post_actions.rbnew file mode 100644index 00000000000..6b23f10974c--- /dev/null+++ b/db/migrate/20190320091323_add_index_post_action_type_id_disagreed_at_on_post_actions.rb@@ -0,0 +1,6 @@+class AddIndexPostActionTypeIdDisagreedAtOnPostActions < ActiveRecord::Migration[5.2]+ def change+ add_index :post_actions, [:post_action_type_id, :disagreed_at],+ where: "(disagreed_at IS NULL)"+ end+end