title: Does the order of conditions in a WHERE clause affect MySQL performance?
body: <p>Say that I have a long, expensive query, packed with conditions, searching a large number of rows. I also have one particular condition, like a company id, that will limit the number of rows that need to be searched considerably, narrowing it down to dozens from hundreds of thousands.</p>
  
  <p>Does it make any difference to MySQL performance whether I do this:</p>
  
  <pre><code> SELECT * FROM clients WHERE 
         (firstname LIKE :foo OR lastname LIKE :foo OR phone LIKE :foo) AND 
         (firstname LIKE :bar OR lastname LIKE :bar OR phone LIKE :bar) AND 
         company = :ugh
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code> SELECT * FROM clients WHERE 
         company = :ugh AND
         (firstname LIKE :foo OR lastname LIKE :foo OR phone LIKE :foo) AND 
         (firstname LIKE :bar OR lastname LIKE :bar OR phone LIKE :bar) 
  </code></pre>