I have a polymorphic association in a Ruby on Rails model. In migration, I have:
create_table "offer_defs" do |t| t.integer "product_def_id" t.string "product_def_type" ... end
I would like to add an index for this association. I hesitate between the following options:
add_index :offer_defs, [:product_def_id, :product_def_type]
or
add_index :offer_defs, :product_def_id add_index :offer_defs, :product_def_type
or maybe both?
What are the pros and cons?
source share