title: Validates Uniqueness getting called when field hasn't changed?
body: <p>Does <code>validates :uniqueness</code> get called every time an object is saved even if a field has not changed? Isn't this a performance issue?</p>
  
  <pre><code>validates :name, :schedule_id, :uniqueness =&gt; true
  </code></pre>
  
  <p>It seems to be the case that it does. So isn't it almost always necessary to make sure a change has taken place before running the validation? As every field being checked for uniqueness requires a database hit.</p>
  
  <p>This would be better:</p>
  
  <pre><code>validates :name, :schedule_id, :uniqueness =&gt; true, :if =&gt; "name_changed? || schedule_id_changed?"
  </code></pre>
  
  <p>And this much better, if a bit more verbose:</p>
  
  <pre><code>validates :name, :uniqueness =&gt; true, :if =&gt; :name_changed?
  validates :schedule_id, :uniqueness =&gt; true, :if =&gt; schedule_id_changed?
  </code></pre>
  
  <p>Gist here: <a href="https://gist.github.com/4017019" rel="nofollow">https://gist.github.com/4017019</a></p>