Skip to content
This repository has been archived by the owner on Mar 20, 2018. It is now read-only.

Commit

Permalink
Improve indexes on sent_emails, better column ordering, removed dupli…
Browse files Browse the repository at this point in the history
…cates.
  • Loading branch information
Mark Steckel committed Aug 20, 2013
1 parent 9337d90 commit 70a36d3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions db/migrate/20130820193236_update_sent_emails_indexes.rb
@@ -0,0 +1,20 @@
class UpdateSentEmailsIndexes < ActiveRecord::Migration
def up
add_index :sent_emails, [:created_at, :type], algorithm: :concurrently

# Using raw sql for 'IF EXISTS'
execute 'DROP INDEX IF EXISTS index_sent_emails_on_type_and_created_at'
execute 'DROP INDEX IF EXISTS index_sent_emails_on_created_at'

# These indexes exist on production and duplicate other indexes
execute 'DROP INDEX IF EXISTS sent_emails_member_id_idx'
execute 'DROP INDEX IF EXISTS sent_emails_created_idx'
end

def down
add_index :sent_emails, [:type, :created_at], algorithm: :concurrently
add_index :sent_emails, [:created_at], algorithm: :concurrently
# Using raw sql for 'IF EXISTS'
execute 'DROP INDEX IF EXISTS index_sent_emails_on_created_at_and_type'
end
end

0 comments on commit 70a36d3

Please sign in to comment.