title: Postgresql doesn't use partial index
body: <p>Postgresql 9.3</p>
  
  <p>I have a table with date_field:</p>
  
  <pre><code>date_field timestamp without time zone
  
  CREATE INDEX ix__table__date_field ON table USING btree (date_field)
      WHERE date_field IS NOT NULL;
  </code></pre>
  
  <p>Then I've tried to use my partial index:</p>
  
  <pre><code>EXPLAIN ANALYZE SELECT count(*) from table where date_field is not null;
  
  Aggregate  (cost=29048.22..29048.23 rows=1 width=0) (actual time=41.714..41.714 rows=1 loops=1)
    -&gt;  Seq Scan on table  (cost=0.00..28138.83 rows=363755 width=0) (actual time=41.711..41.711 rows=0 loops=1)
          Filter: (date_field IS NOT NULL)
          Rows Removed by Filter: 365583
  Total runtime: 41.744 ms
  </code></pre>
  
  <p>But it uses partial index with comparing dates:</p>
  
  <pre><code>EXPLAIN ANALYZE SELECT count(*) from table where date_field &gt; '2015-1-1';
  
  Aggregate  (cost=26345.51..26345.52 rows=1 width=0) (actual time=0.006..0.007 rows=1 loops=1)
    -&gt;  Bitmap Heap Scan on table  (cost=34.60..26040.86 rows=121861 width=0) (actual time=0.005..0.005 rows=0 loops=1)
          Recheck Cond: (date_field &gt; '2015-01-01 00:00:00'::timestamp without time zone)
          -&gt;  Bitmap Index Scan on ix__table__date_field  (cost=0.00..4.13 rows=121861 width=0) (actual time=0.003..0.003 rows=0 loops=1)
                Index Cond: (date_field &gt; '2015-01-01 00:00:00'::timestamp without time zone)
  Total runtime: 0.037 ms
  </code></pre>
  
  <p>So, why it doesn't use index on <code>date_field is not null</code>?</p>
  
  <p>Thanks in advance!</p>