Re: Index Scans Oddness

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: o2(at)trustcommerce(dot)com
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: Index Scans Oddness
Date: 2001-10-12 19:47:55
Message-ID: 1188.1002916075@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-bugs pgsql-general

Orion <o2(at)trustcommerce(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2001-10-12 19:50:36 Re: psql \l problem
Previous Message Bruce Momjian 2001-10-12 18:22:11 Re: Intel C++ Compiler

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2001-10-13 01:21:03 Re: Bug #477: path ?# path
Previous Message Dave Page 2001-10-12 19:40:13 Re: Possible bug in ALTER TABLE RENAME COLUMN (PostgreSQL

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Boes 2001-10-12 20:01:30 Re: PG mailing list problems (was Re: Support issues)
Previous Message Doug McNaught 2001-10-12 19:45:39 Re: COMMIT after an ERROR?