PERF: add index on user email logs

This index makes it much faster to figure out if a user reached
email limit on sites where lots of emails are skipped
This commit is contained in:
Sam Saffron 2018-02-07 11:33:15 -05:00
parent 8765279c90
commit fb91d24deb
1 changed files with 8 additions and 0 deletions

View File

@ -0,0 +1,8 @@
class AddSkippedCreatedAtUserIdIndexOnEmailLogs < ActiveRecord::Migration[5.1]
def up
execute "CREATE INDEX idx_email_logs_user_created_filtered ON email_logs(user_id, created_at) WHERE skipped = 'f'"
end
def down
execute "DROP INDEX idx_email_logs_user_created_filtered"
end
end