title: MySQL count(DISTINCT) very slow - better with subqueries?
body: <p>I have one flat table, with about 10mio rows, each row has 15 columns.
  Index are set to column_1, column_2, column_3 and my_time.</p>
  
  <pre><code>  SELECT    Date(my_time) my_time, 
              count(DISTINCT column_1) c_c1, 
              count(DISTINCT column_2) c_c2 
      FROM    `table_name` 
     WHERE    `column_3` in (10,11,100,50,213,756) 
       AND    Date(my_time) &gt; '2016-09-01' 
       AND    Date(my_time) &lt; '2016-09-30' 
  GROUP BY    Date(my_time) 
  ORDER BY    Date(my_time) ASC
  </code></pre>
  
  <p>Results took about 20-30 seconds.</p>
  
  <p>Does anybody know, how to improve this query, maybe with subqueries?
  In case of subquery, can you show me an example query, how to increase the performance?</p>
  
  <p>thanks!</p>