Skip to content

Commit

Permalink
Add indexes to fields commonly used in queries to build emails (#9551)
Browse files Browse the repository at this point in the history
## Context

When I looked at the email queries earlier, it was clear could
potentially send nudges to candidates who couldn't do anything with them
(users whose accounts were blocked or locked for some reason). So we
added those filters.

This PR just adds indexes to those fields to help speed up queries. 

## Changes proposed in this pull request

This PR just adds indexes to those fields to help speed up queries.
  • Loading branch information
elceebee authored Jan 9, 2025
1 parent a9e793a commit d52bc38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddIndexesToEmailRelatedFilters < ActiveRecord::Migration[7.1]
disable_ddl_transaction!

def change
add_index :candidates, :submission_blocked, algorithm: :concurrently
add_index :candidates, :account_locked, algorithm: :concurrently
add_index :candidates, :unsubscribed_from_emails, algorithm: :concurrently
end
end
3 changes: 3 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,12 @@
t.boolean "submission_blocked", default: false, null: false
t.boolean "account_locked", default: false, null: false
t.string "account_recovery_status", default: "not_started", null: false
t.index ["account_locked"], name: "index_candidates_on_account_locked"
t.index ["email_address"], name: "index_candidates_on_email_address", unique: true
t.index ["fraud_match_id"], name: "index_candidates_on_fraud_match_id"
t.index ["magic_link_token"], name: "index_candidates_on_magic_link_token", unique: true
t.index ["submission_blocked"], name: "index_candidates_on_submission_blocked"
t.index ["unsubscribed_from_emails"], name: "index_candidates_on_unsubscribed_from_emails"
end

create_table "chasers_sent", force: :cascade do |t|
Expand Down

0 comments on commit d52bc38

Please sign in to comment.