title: Rails/Active Record .save! efficiency question
body: <p>New to rails/ruby (using rails 3 and ruby 1.9.2), and am trying to get rid of some unnecessary queries being executed.  </p>
  
  <p>When I'm running an each do:</p>
  
  <pre><code>apples.to_a.each do |apple|
    new_apple = apple.clone
    new_apple.save!
  end
  </code></pre>
  
  <p>and I check the sql LOG, I see three select statements followed by one insert statement.  The select statements seem completely unnecessary.  For example, they're something like:  </p>
  
  <p>SELECT Fruit.* from Fruits where Fruit.ID = 5 LIMIT 1; <br />
  SELECT Color.* from Colors where Color.ID = 6 LIMIT 1; <br />
  SELECT TreeType.* from TreeTypes where TreeType.ID = 7 LIMIT 1; <br />
  INSERT into Apples (Fruit_id, color_id, treetype_id) values (6, 7, 8) RETURNING "id";</p>
  
  <p>Seemingly, this wouldnt' take much time, but when I've got 70k inserts to run, I'm betting those three selects for each insert will take up a decent amount of time.  </p>
  
  <p>So I'm wondering the following:</p>
  
  <ul>
  <li>Is this typical of ActiveRecord/Rails .save! method, or did the previous developer add some sort of custom code?</li>
  <li>Would those three select statements, being executed for each item, cause a noticeable amount of extra time? </li>
  <li>If it is built into rails/active record, would it be easily bypassed, if that would make it run more efficiently? </li>
  </ul>