title: Performance of multi-column MySQL indexes when using only one column in a query
body: <p>I have a query on my database as such:</p>
  
  <pre><code>SELECT * FROM expenses WHERE user_id = ? AND dated_on = ?
  </code></pre>
  
  <p>I have added an index to the table on both the <code>user_id</code> and <code>dated_on</code> columns.  When I inspect the indexes using <code>SHOW INDEXES FROM expenses</code>, there are two lines -- one with a <code>seq_in_index</code> value of 1, the other with a <code>seq_in_index</code> value of 2.</p>
  
  <p>My question is, if I then submit a query which uses only one of the two WHERE clauses, e.g.:</p>
  
  <pre><code>SELECT * FROM expenses WHERE user_id = ?
  </code></pre>
  
  <p>Is there any benefit to creating another index which solely indexes the <code>user_id</code> column, or will the <code>user_id</code>/<code>dated_on</code> index described above be used just as efficiently?</p>
  
  <p>Finally, how about if use the query:</p>
  
  <pre><code>SELECT * FROM expenses WHERE dated_on = ?
  </code></pre>
  
  <p>How does the <code>seq_in_index</code> value of 2 affect index use and performance in this situation?</p>