Re: Index Scans Oddness - Mailing list pgsql-general

From Tom Lane
Subject Re: Index Scans Oddness
Date
Msg-id 1188.1002916075@sss.pgh.pa.us
Whole thread Raw
In response to Index Scans Oddness  (Orion <o2@trustcommerce.com>)
List pgsql-general
Orion <o2@trustcommerce.com> writes:
>         select * from foo where text_field like 'foo%'
> will do an index scan with my data in 7.0.3 but not 7.1.3-1PGDG.
> Makes me think there's a bug.

Yes: in 7.0.  You're probably running in a non-C locale, wherein
optimizing LIKE with an indexscan is unsafe.

>         select * from foo where order_date = current_date
> and
>         select * from foo
>         where order_date < to_date(xxx) and order_date > to_date(yyy)

> Both do sequence scans where current date is indexed

The problem is probably lack of cachability of current_date and to_date().
You can fix this with a wrapper function that's marked "iscachable".
Look in the mailing list archives for prior discussions.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: "Relation x does not exist" error when x does exist
Next
From: Palle Girgensohn
Date:
Subject: Re: Unixtime from timedate?