mirror of
https://github.com/discourse/discourse.git
synced 2025-02-06 11:28:18 +00:00
PERF: add missing bounce_key index to email_logs
We perform lookups based off bounce_key when emails bounce, we need the index.
This commit is contained in:
parent
3dc4ab905c
commit
bb8cdf9e5f
@ -0,0 +1,14 @@
|
||||
class AddBounceKeyIndexOnEmailLogs < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
execute <<~SQL
|
||||
DELETE FROM email_logs l
|
||||
WHERE bounce_key IS NOT NULL
|
||||
AND id > (
|
||||
SELECT MIN(id)
|
||||
FROM email_logs l2
|
||||
WHERE l2.bounce_key = l.bounce_key
|
||||
)
|
||||
SQL
|
||||
add_index :email_logs, [:bounce_key], unique: true, where: 'bounce_key IS NOT NULL'
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user