Re: No Index-Only Scan on Partial Index - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: No Index-Only Scan on Partial Index
Date
Msg-id 12972596-5190-4CAF-8169-2EDF48483E42@justatheory.com
Whole thread Raw
In response to Re: No Index-Only Scan on Partial Index  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-hackers
On Oct 2, 2013, at 5:07 AM, Merlin Moncure <mmoncure@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.63rows=33333 width=68)  Filter: upper_inf(irange)  ->  Bitmap Index Scan on try_upper_inf_idx
(cost=0.00..927.30rows=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
Postgresdoesn't do an index scan. Is this something that could be improved in the planner? 

Thanks,

David




pgsql-hackers by date:

Previous
From: Steve Singer
Date:
Subject: Re: logical changeset generation v6.2
Next
From: Kevin Grittner
Date:
Subject: Re: record identical operator - Review