title: Mysql inner join count query too slow
body: <p>I am trying to get count query with a simple inner join sentence. I have created index for all attributes. Query is very slow: (12 seconds). I have 4 million of records in Table1 and Table 2. This is my query:</p>
  
  <pre><code> select count(*)
   from (`mymodb`.`Table1`
       join `mymodb`.`Table2` on ((`mymodb`.`Table2`.`id` =`mymodb`.`Table1`.`id_table1`)))
   where (`mymodb`.`Table2`.`merchant_id` = 16444)
     and Table1.created_at &gt;= '2017-12-03 16:00:19' AND  Table1.created_at &lt;='2018-05-03 16:00:19';
  </code></pre>
  
  <p>This is desc query command (see 5.524.164 records):</p>
  
  <pre><code>1   SIMPLE  Table1      ALL Table12_index,Table16_index             5524164 21.38   Using where
  1   SIMPLE  Table2      eq_ref  PRIMARY,idx_Table2_id-uniq,Table26_index    PRIMARY 8   mymodb.Table1.id_table1 1   50  Using where
  </code></pre>
  
  <p>Table2</p>
  
  <p>Which would be the best way to get count query with inner join of two tables (Table 1 --- Table2). 12 Seconds is very poor time for my process.</p>