title: MySQL: Composite Index vs Multiple Indices (Leftmost Index Prefixes)
body: <p>We have a table that is currently using a composite (i.e. multi-column) index.</p>
  
  <p>Let's say</p>
  
  <pre><code>PRIMARY KEY(A, B)
  </code></pre>
  
  <p>Of course we can rapidly search based on A alone (<strong>Leftmost Index Prefix</strong>) and if we want to efficiently search based on B alone, we need to create a separate index for B.</p>
  
  <p>My question is that if I am doing:</p>
  
  <pre><code>PRIMARY KEY (B)
  </code></pre>
  
  <p>is there any value in retaining </p>
  
  <pre><code>PRIMARY KEY (A,B)
  </code></pre>
  
  <p><strong>In other words</strong> will there be any advantage retaining</p>
  
  <pre><code>PRIMARY KEY (A,B)
  </code></pre>
  
  <p>if I have </p>
  
  <pre><code>PRIMARY KEY (A)
  </code></pre>
  
  <p>and  </p>
  
  <pre><code>PRIMARY KEY (B)
  </code></pre>