title: best way to search 2 columns in MySQL
body: <p>I have a table (T1) with ca. 500000 records:</p>
  
  <pre><code>    ID1    Relation  ID2
      4      Rel41      3
      5      Rel21      7
      13     Rel2       4
  </code></pre>
  
  <p>What is the efficient way to retrieve the records that the value 4 exist in:</p>
  
  <p>The result should be: </p>
  
  <pre><code> 4 Rel41 3
   13 Rel2 4  
  </code></pre>
  
  <p>I tried multiple-column index as follows:</p>
  
  <pre><code>create table T1 (
      ID1 varchar(5), 
      Relation varchar(50), 
      ID2 varchar(5), 
      PRIMARY KEY (ID1,ID2)
  ); 
  </code></pre>
  
  <p>and then I used select statement as follows:</p>
  
  <pre><code> select * from T1 WHERE ID1=4 OR ID2=4 ;
  </code></pre>
  
  <p>This was even slower than using no multiple-column index.</p>
  
  <p>which type of index should be used here?</p>