Received: from mail1.hub.org (webmail.hub.org [216.126.85.1]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9CK4pr00429 for ; Fri, 12 Oct 2001 16:04:51 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.pgh.pa.us ([192.204.191.242]) by mail1.hub.org (8.11.3/8.11.4) with ESMTP id f9CJm5X93503 for ; Fri, 12 Oct 2001 15:48:05 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id f9CJltI01191; Fri, 12 Oct 2001 15:47:56 -0400 (EDT) To: o2@trustcommerce.com cc: pgsql-general@postgreSQL.org Subject: Re: Index Scans Oddness In-reply-to: <9q51rs$2o4b$1@news.tht.net> References: <9q51rs$2o4b$1@news.tht.net> Comments: In-reply-to Orion message dated "Thu, 11 Oct 2001 14:14:33 -0700" Date: Fri, 12 Oct 2001 15:47:55 -0400 Message-ID: <1188.1002916075@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200110/297 X-Sequence-Number: 16106 Orion 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