title: MySQL not using indexes with WHERE IN clause?
body: <p>I'm trying to optimize some of the database queries in my Rails app and I have several that have got me stumped.  They are all using an <code>IN</code> in the <code>WHERE</code> clause and are all doing full table scans even though an appropriate index appears to be in place.</p>
  
  <p>For example:</p>
  
  <pre><code>SELECT `user_metrics`.* FROM `user_metrics` WHERE (`user_metrics`.user_id IN (N,N,N,N,N,N,N,N,N,N,N,N))
  </code></pre>
  
  <p>performs a full table scan and <code>EXPLAIN</code> says:</p>
  
  <pre><code>select_type: simple
  type: all
  extra: using where
  possible_keys: index_user_metrics_on_user_id  (which is an index on the user_id column)
  key: (none)
  key_length: (none)
  ref: (none)
  rows: 208
  </code></pre>
  
  <p>Are indexes not used when an <code>IN</code> statement is used or do I need to do something differently?  The queries here are being generated by Rails so I could revisit how my relationships are defined, but I thought I'd start with potential fixes at the DB level first.</p>