title: MySQL Performance - "IN" Clause vs. Equals (=) for a Single Value
body: <p>This is a pretty simple question and I'm assuming the answer is "It doesn't matter" but I have to ask anyway...</p>
  
  <p>I have a generic sql statement built in PHP:</p>
  
  <pre><code>$sql = 'SELECT * FROM `users` WHERE `id` IN(' . implode(', ', $object_ids) . ')';
  </code></pre>
  
  <p>Assuming prior validity checks (<code>$object_ids</code> is an array with at least 1 item and all numeric values), should I do the following instead?</p>
  
  <pre><code>if(count($object_ids) == 1) {
      $sql = 'SELECT * FROM `users` WHERE `id` = ' . array_shift($object_ids);
  } else {
      $sql = 'SELECT * FROM `users` WHERE `id` IN(' . implode(', ', $object_ids) . ')';
  }
  </code></pre>
  
  <p>Or is the overhead of checking <code>count($object_ids)</code> not worth what would be saved in the actual sql statement (if any at all)?</p>