X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id E9CCC9FA2AD for ; Tue, 22 Aug 2006 15:21:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 18959-04 for ; Tue, 22 Aug 2006 18:21:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by postgresql.org (Postfix) with ESMTP id 9263C9FB300 for ; Tue, 22 Aug 2006 15:21:24 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id p77so148131nfc for ; Tue, 22 Aug 2006 11:21:23 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=WUilhXfpuLvCc66V3+IPtLheTsw9PB59Teme+0mhoMI8T9xjR5OrsnpNjYloM/4mT0hfA5fPwzQyxG1R6OqslPUhhRmlgOWCUXiTL+X1FvGzVYa79czy+lC5fTHxdL69iaYTEw4cXcpRrpESV1Iud9prYqy49JpTm0K+TyBPOVY= Received: by 10.66.252.4 with SMTP id z4mr4555771ugh; Tue, 22 Aug 2006 11:21:23 -0700 (PDT) Received: by 10.67.28.18 with HTTP; Tue, 22 Aug 2006 11:21:23 -0700 (PDT) Message-ID: <4e96c6600608221121p2afc603bx90fcf879aab47d96@mail.gmail.com> Date: Tue, 22 Aug 2006 20:21:23 +0200 From: "Thomas Samson" To: "Ulrich Habel" , pgsql-performance@postgresql.org Subject: Re: query planner: automatic rescribe of LIKE to BETWEEN ? In-Reply-To: <20060822174539.GD25475@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200608221922.59734.espero7757@gmx.net> <20060822174539.GD25475@alvh.no-ip.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.816 tagged_above=0 required=5 tests=SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: *** X-Archive-Number: 200608/350 X-Sequence-Number: 20535 On 8/22/06, Alvaro Herrera wrote: > Ulrich Habel wrote: > > Hello all, > > had an idea of optimizing a query that may work generally. > > > > In case a 'column' is indexed, following two alterations could be done > > I think: > > > > A) > > > > select ... where column ~ '^Foo' --> Seq Scan > > This is not true. You can make this query use an index if you create it > with opclass varchar_pattern_ops or text_pattern_ops, as appropiate. > > Thus you don't need any hack here. > And in the case of more general expression, like: select ... where column ~ 'something'; Is there a way to optimise this ? (in the case where 'something' is not a word, but a part of a word) -- Thomas SAMSON