X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8956552886 for ; Tue, 28 Jun 2005 02:16:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18157-06 for ; Tue, 28 Jun 2005 05:16:30 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id A0A7252813 for ; Tue, 28 Jun 2005 02:16:28 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j5S5GQun084639 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 27 Jun 2005 23:16:28 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j5S5GQG4018317; Mon, 27 Jun 2005 23:16:26 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j5S5GQYs018316; Mon, 27 Jun 2005 23:16:26 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 27 Jun 2005 23:16:26 -0600 From: Michael Fuhr To: Aditya Damle Cc: pgsql-performance@postgresql.org Subject: Re: LIKE search with ending % not optimized in v8 Message-ID: <20050628051626.GA18240@winnie.fuhr.org> References: <20050622090329.34686.qmail@web32910.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050622090329.34686.qmail@web32910.mail.mud.yahoo.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/540 X-Sequence-Number: 13177 On Wed, Jun 22, 2005 at 02:03:29AM -0700, Aditya Damle wrote: > > Hello. I believe in earlier versions, a query of the > form > select attrib from ttt where attrib like 'foo%' would > be able to take advantage of an index. I have seen > this in the past. Currently I am using v8.0.3. From > what I can see is that the execultion plan seems to > use a seq scan and to totally ignore the index. Is > this the case? 8.0.3 can certainly use indexes for LIKE queries, but the planner will choose a sequential scan if it thinks that would be faster. Have you vacuumed and analyzed your tables? Could you post the EXPLAIN ANALYZE output of a query, once with enable_seqscan turned on and once with it turned off? See also "Operator Classes" in the "Indexes" chapter of the documentation: http://www.postgresql.org/docs/8.0/static/indexes-opclass.html What locale are you using? -- Michael Fuhr http://www.fuhr.org/~mfuhr/