cirandas.net

ref: master

db/migrate/20120401211857_add_indexes_for_product_and_related.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class AddIndexesForProductAndRelated < ActiveRecord::Migration
  def self.up
    # reduced from 75% to 5% postgres' cpu usage during solr indexing :)
    add_index :products, :product_category_id
    add_index :inputs, :product_category_id
    add_index :inputs, :product_id
    add_index :product_qualifiers, :product_id
    add_index :product_qualifiers, :qualifier_id
    add_index :product_qualifiers, :certifier_id
    add_index :profiles, :region_id
  end

  def self.down
    remove_index :products, :product_category_id
    remove_index :inputs, :product_category_id
    remove_index :inputs, :product_id
    remove_index :product_qualifiers, :product_id
    remove_index :product_qualifiers, :qualifier_id
    remove_index :product_qualifiers, :certifier_id
    remove_index :profiles, :region_id
  end
end