X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 527F511F6602 for ; Tue, 25 Apr 2006 15:24:57 -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 77420-08 for ; Tue, 25 Apr 2006 15:24:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id B915511F6553 for ; Tue, 25 Apr 2006 15:24:45 -0300 (ADT) Received: by noel.decibel.org (Postfix, from userid 1001) id C25E656423; Tue, 25 Apr 2006 13:24:45 -0500 (CDT) Received: (hashcash-sendmail, from uid 1001); Tue, 25 Apr 2006 13:24:45 -0500 Date: Tue, 25 Apr 2006 13:24:45 -0500 From: "Jim C. Nasby" To: Sriram Dandapani Cc: "Pgsql-Performance (E-mail)" Subject: Re: planner not using index for like operator Message-ID: <20060425182444.GK97354@pervasive.com> References: <6992E470F12A444BB787B5C937B9D4DF0406B241@ca-mail1.cis.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF0406B241@ca-mail1.cis.local> X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Hashcash: 1:20:060425:sdandapani@counterpane.com::e21kxcYqrLpZRt2b:00000000000 0000000000000000000000003+28 X-Hashcash: 1:20:060425:pgsql-performance@postgresql.org::BZGbhDtVoVwpSHit:00000 0000000000000000000000002wQJ X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/561 X-Sequence-Number: 18645 On Tue, Apr 25, 2006 at 10:08:02AM -0700, Sriram Dandapani wrote: Here's the key: > " Filter: ((col1)::text ~~ '172.%'::text)" In order to do a like comparison, it has to convert col1 (which I'm guessing is of type 'inet') to text, so there's no way it can use an index on col1 (maybe a function index, but that's a different story). Is there some reason you're not doing WHERE col1 <<= '172/8'::inet ? -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461