title: MySql not picking correct index for few queries
body: <p>I'm running follwing query on the table, I'm changing values in the where condition, while running in one case it's taking one index and another case taking it's another(wrong??) index.</p>
  
  <p>row count for query 1 is 402954 it's taking approx 1.5 sec</p>
  
  <p>row count for query 2 is 52097 it's taking approx 35 sec</p>
  
  <p>Both queries query 1 and query 2 are same , only I'm changing values in the where condition</p>
  
  <p>query 1</p>
  
  <pre><code>EXPLAIN SELECT 
       log_type,count(DISTINCT subscriber_id) AS distinct_count,
       count(subscriber_id) as total_count 
  FROM campaign_logs 
  WHERE 
      domain = 'xxx' AND 
      campaign_id='123' AND 
      log_type IN ('EMAIL_SENT', 'EMAIL_CLICKED', 'EMAIL_OPENED', 'UNSUBSCRIBED') AND 
      log_time BETWEEN 
         CONVERT_TZ('2015-02-12 00:00:00','+05:30','+00:00') AND
         CONVERT_TZ('2015-02-19 23:59:58','+05:30','+00:00') 
  GROUP BY log_type;
  </code></pre>
  
  <p>EXPLAIN of above query</p>
  
  <pre><code>+----+-------------+---------------+-------+------------------------------------------------------------------------------------------------------+-----------------------------------------+---------+------+--------+-------------+
  | id | select_type | table         | type  | possible_keys                                                                                        | key                                     | key_len | ref  | rows   | Extra       |
  +----+-------------+---------------+-------+------------------------------------------------------------------------------------------------------+-----------------------------------------+---------+------+--------+-------------+
  |  1 | SIMPLE      | campaign_logs | range | campaign_id_index,domain_index,log_type_index,log_time_index,campaignid_domain_logtype_logtime_index | campaignid_domain_logtype_logtime_index | 468     | NULL | 402954 | Using where |
  +----+-------------+---------------+-------+------------------------------------------------------------------------------------------------------+-----------------------------------------+---------+------+--------+-------------+
  </code></pre>
  
  <p>query 2</p>
  
  <pre><code>EXPLAIN SELECT 
      log_type,count(DISTINCT subscriber_id) AS distinct_count,
      count(subscriber_id) as total_count 
  FROM stats.campaign_logs 
  WHERE 
      domain = 'yyy' AND 
      campaign_id='345' AND 
      log_type IN ('EMAIL_SENT', 'EMAIL_CLICKED', 'EMAIL_OPENED', 'UNSUBSCRIBED') AND 
      log_time BETWEEN 
           CONVERT_TZ('2014-02-05 00:00:00','+05:30','+00:00') AND
           CONVERT_TZ('2015-02-19 23:59:58','+05:30','+00:00') 
  GROUP BY log_type;
  </code></pre>
  
  <p>explain of above query</p>
  
  <pre><code>+----+-------------+---------------+-------------+------------------------------------------------------------------------------------------------------+--------------------------------+---------+------+-------+------------------------------------------------------------------------------+
  | id | select_type | table         | type        | possible_keys                                                                                        | key                            | key_len | ref  | rows  | Extra                                                                        |
  +----+-------------+---------------+-------------+------------------------------------------------------------------------------------------------------+--------------------------------+---------+------+-------+------------------------------------------------------------------------------+
  |  1 | SIMPLE      | campaign_logs | index_merge | campaign_id_index,domain_index,log_type_index,log_time_index,campaignid_domain_logtype_logtime_index | campaign_id_index,domain_index | 153,153 | NULL | 52097 | Using intersect(campaign_id_index,domain_index); Using where; Using filesort |
  +----+-------------+---------------+-------------+------------------------------------------------------------------------------------------------------+--------------------------------+---------+------+-------+------------------------------------------------------------------------------+
  </code></pre>
  
  <p>Query 1 is using correct index because I have composite index </p>
  
  <p>Query 2 is using index merge , it's taking long time to execute</p>
  
  <p>Why MySql using different indexes for same query</p>
  
  <p>I know we can mention USE INDEX in the query , but why MySql is not picking correct index in this case??. am I doing anything wrong??</p>