title: Mysql - Aggregate function is very slow
body: <p>I have a mysql database with very large tables. I often run queries that involve aggregate functions. Queries with the aggregate functions like MIN, MAX, SUM, COUNT are running very slow. Please help me to increase the speed.</p>
  
  <pre><code>SELECT MIN(PeriodTime) FROM ResultsTable WHERE (OrderId=271)
  SELECT COUNT(*) FROM ResultsTable WHERE (OrderId=271);  ==&gt; returns 258021
  </code></pre>
  
  <p>Total rows in that table = 1213284, My Query matches = 258021 rows.</p>
  
  <p>I appreciate any help. Thank you.</p>