On Oct 2, 2013, at 5:07 AM, Merlin Moncure <mmonc...@gmail.com> wrote:

> > Hrm. I get a seq scan for that query:
> >
> > create index on try(upper_inf(irange));
> > explain select * from try where upper_inf(irange);
> >                         QUERY PLAN
> > -----------------------------------------------------------
> >  Seq Scan on try  (cost=0.00..1887.00 rows=33333 width=68)
> >    Filter: upper_inf(irange)
> >
> > True also if I just select the irange. Is the filter the issue, here?
> 
> Turn off seq scan...

That rewards me with a bitmap heap scan:

EXPLAIN select * from try where upper_inf(irange);

                                      QUERY PLAN                                
      
--------------------------------------------------------------------------------------
 Bitmap Heap Scan on try  (cost=935.63..2197.63 rows=33333 width=68)
   Filter: upper_inf(irange)
   ->  Bitmap Index Scan on try_upper_inf_idx  (cost=0.00..927.30 rows=50000 
width=0)
         Index Cond: (upper_inf(irange) = true)

But anyway, I still don’t understand why, if the function used to store the 
value is immutable (as upper_inf() is), why Postgres doesn't do an index scan. 
Is this something that could be improved in the planner?

Thanks,

David



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to