title: Why is MySQL preferring a single index over a composite index?
body: <p>I currently have this query:</p>
  <pre><code>SELECT 
      *
  FROM
      (`session`)
  WHERE
      (`session`.`isSale` = 0)
          AND (`session`.`createDatetime` &gt;= (NOW() - INTERVAL 3 WEEK))
          AND (`session`.`sellerName` IS NOT NULL)
  GROUP BY `session`.`id`
  ORDER BY `session`.`id` DESC;
  </code></pre>
  <p>and I have the below indexes:</p>
  <pre><code>idx_createDatetime (`createDatetime` ASC)
  idx_isSale (`isSale` ASC)
  idx_sellerName (`sellerName` ASC)
  idx_isSale_createDatetime_sellerName (`isSale` ASC, `createDatetime` ASC, `sellerName` ASC)
  idx_createDatetime_isSale_sellerName (`createDatetime` ASC, `isSale` ASC, `sellerName` ASC)
  idx_createDatetime_sellerName_isSale (`createDatetime` ASC, `sellerName` ASC, `isSale` ASC)
  </code></pre>
  <p>When using <strong>EXPLAIN</strong> before the query, to check it out, I'm finding that the index that's being used is <strong>idx_createDatetime</strong></p>
  <p>Is there a specific reason why MySQL is deciding to go with a basic index, when there are better indexes to use?</p>