title: PostgreSQL: Create index for boolean column
body: <p>I have a table that has one boolean column. </p>
  
  <pre><code>productid integer
  isactive boolean
  </code></pre>
  
  <p>When I execute the query</p>
  
  <pre><code>SELECT productid   
      FROM 
      product  
      WHERE ispublish
      LIMIT 15 OFFSET  0
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/AyMho.png" alt="enter image description here"></p>
  
  <p>After that, I created an index for the <code>ispublish</code> column:</p>
  
  <pre><code>CREATE INDEX idx_product_ispublish ON product USING btree (ispublish)
  </code></pre>
  
  <p>and re-execute</p>
  
  <pre><code>SELECT productid   
         FROM 
         product  
         WHERE ispublish
         LIMIT 15 OFFSET  0
  </code></pre>
  
  <p>The result:</p>
  
  <p><img src="https://i.stack.imgur.com/iiqOG.png" alt="enter image description here"></p>
  
  <p>=> No difference</p>
  
  <p>I've been tried the following, but the results are the same:</p>
  
  <pre><code>CREATE INDEX idx_product_ispublish ON product USING btree (ispublish)
  
  CREATE INDEX idx_product_ispublish ON product USING btree (ispublish)
  
  CREATE INDEX idx_product_ispublish ON product (ispublish) WHERE ispublish is TRUE
  </code></pre>
  
  <p>Who can explain that to me?</p>