title: bitwise mask vs IN() efficiency in sqlite?
body: <p>I have two ways to select a set of entries from the database:</p>
  
  <pre><code>  SELECT ... WHERE `level` IN (1,2,4,8) LIMIT ...;  
  </code></pre>
  
  <p>or</p>
  
  <pre><code>  SELECT ... WHERE `level` &amp; mask LIMIT ...;
  </code></pre>
  
  <p>There are 4 'levels' total, numbered 1,2,4,8 (for reasons of ability to use the same mask elsewhere too). Both the braces of <code>IN()</code> or the <code>mask</code> can contain any set of one or more of the 4 levels. The column is indexed. The query is still taking way longer than comfortable, and we're trying to optimize it for speed.</p>
  
  <p>Yesterday one person said decided using naive IN() results in up to four comparisons and that I should be using a bit mask instead. Today I heard the bit mask will completely thwart advantages from index on the column, and will be much slower.</p>
  
  <p>Can you tell me which approach will be faster?</p>