title: How can I optimise this MySQL query?
body: <p>I am using the following MySQL query in a PHP script on a database that contains over 370,000,000 (yes, three hundred and seventy million) rows. I know that it is extremely resource intensive and it takes ages to run this one query. Does anyone know how I can either optimise the query or get the information in another way that's quicker?</p>
  
  <p>Table Info:<pre>games | longint, unsigned, Primary Key
  win   | bit(1)
  loss  | bit(1)</pre></p>
  
  <p>Query:<pre>SELECT MID(<code>game</code>,{$len},1) AS <code>move</code>,
         COUNT(*) AS <code>games</code>,
         SUM(<code>win</code>) AS <code>wins</code>,
         SUM(<code>loss</code>) AS <code>losses</code>
  FROM <code>games</code>
  WHERE <code>game</code>>{$something} AND <code>game</code>&lt;{$something_else}
  GROUP BY <code>move</code></pre></p>
  
  <p>Thanks in advance for your help!</p>