X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 14F949FB274 for ; Tue, 22 Aug 2006 14:46:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 10734-02 for ; Tue, 22 Aug 2006 14:46:02 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from lists.commandprompt.com (host-130.commandprompt.net [207.173.203.130]) by postgresql.org (Postfix) with ESMTP id 20E5D9FA5FB for ; Tue, 22 Aug 2006 14:46:01 -0300 (ADT) Received: from alvh.no-ip.org (201-221-200-187.bk11-dsl.surnet.cl [201.221.200.187]) (authenticated bits=0) by lists.commandprompt.com (8.13.7/8.13.6) with ESMTP id k7MHjxB8011580; Tue, 22 Aug 2006 10:46:00 -0700 Received: by alvh.no-ip.org (Postfix, from userid 1000) id 2E147C2DC58; Tue, 22 Aug 2006 13:45:39 -0400 (CLT) Date: Tue, 22 Aug 2006 13:45:39 -0400 From: Alvaro Herrera To: Ulrich Habel Cc: pgsql-performance@postgresql.org Subject: Re: query planner: automatic rescribe of LIKE to BETWEEN ? Message-ID: <20060822174539.GD25475@alvh.no-ip.org> Mail-Followup-To: Ulrich Habel , pgsql-performance@postgresql.org References: <200608221922.59734.espero7757@gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200608221922.59734.espero7757@gmx.net> User-Agent: Mutt/1.5.12-2006-07-14 X-Virus-Scanned: ClamAV version 0.88.3, clamav-milter version 0.88.3 on projects.commandprompt.com X-Virus-Status: Clean X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (lists.commandprompt.com [192.168.2.159]); Tue, 22 Aug 2006 10:46:00 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.423 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200608/349 X-Sequence-Number: 20534 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. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support