title: SQL - left join with OR operator (MySQL)
body: <p>I have a left join on a MySQL database like this...<br></p>
  
  <pre><code>select  *
  from tableA 
  left join tableB on (tableA.id=tableB.id1 and tableB.col2='Red')
  </code></pre>
  
  <p><strong>...which performs OK with >500K rows on tableA and tableB</strong></p>
  
  <p>However, changing it to this (and assuming indexes are OK)...<br></p>
  
  <pre><code>select  *
  from tableA 
  left join tableB on 
  ((tableA.id=tableB.id1 and tableB.col2='Red') OR
   (tableA.id=tableB.id2 and tableB.col2='Blue') )
  </code></pre>
  
  <p>...kills it, in terms of performance.</p>
  
  <p>So why the performance hit? Can I do it another way?</p>