title: Do I need to manually add indexes to my foreign key fields or does Rails do it automatically?
body: <p>I've read about how indexes applied to foreign key fields are important for application speed performance, but I've also read contradictory statements about how to set these up. In the structure shown in my model and migration files below:</p>
  
  <pre><code>class Owner &lt; ApplicationRecord
    has_many :dogs
  end
  
  class Dog &lt; ApplicationRecord
    belongs_to :owner
  end
  
  create_table :owners do |t|
    t.string :full_name
    t.string :address
    t.timestamps
  end
  
  create_table :dogs do |t|
    t.string :name
    t.string :age
    t.string :breed
    t.references :owner, foreign_key: true
    t.timestamps
  end
  </code></pre>
  
  <p>On the line where I declare my foreign key field:</p>
  
  <pre><code>t.references :owner, foreign_key: true
  </code></pre>
  
  <p>If I leave it like this, will Rails automatically create a database index for me, or do I need to add one manually by modifying the line to display the code below?</p>
  
  <pre><code>t.references :owner, foreign_key: true, index: true
  </code></pre>
  
  <p>Or if I do need to add the index manually, do I instead need to declare it with the <strong>add_index</strong> method in a separate block of code? In which case, what is the point of <strong>index: true</strong>?</p>
  
  <p>I'm using Rails 5.1.4</p>