X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 8D9E99DC845 for ; Wed, 11 Jan 2006 17:02:26 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86977-06 for ; Wed, 11 Jan 2006 17:02:25 -0400 (AST) 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 51E8A9DC98E for ; Wed, 11 Jan 2006 17:02:20 -0400 (AST) Received: by noel.decibel.org (Postfix, from userid 1001) id D64EC39849; Wed, 11 Jan 2006 15:02:21 -0600 (CST) Date: Wed, 11 Jan 2006 15:02:21 -0600 From: "Jim C. Nasby" To: Andrea Arcangeli Cc: pgsql-performance@postgresql.org Subject: Re: NOT LIKE much faster than LIKE? Message-ID: <20060111210221.GD63175@pervasive.com> References: <20060110014447.GB18474@opteron.random> <20060111184032.GS3902@pervasive.com> <20060111203947.GL15897@opteron.random> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060111203947.GL15897@opteron.random> X-Operating-System: FreeBSD 6.0-RELEASE amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.088 required=5 tests=[AWL=0.088] X-Spam-Score: 0.088 X-Spam-Level: X-Archive-Number: 200601/125 X-Sequence-Number: 16603 On Wed, Jan 11, 2006 at 09:39:47PM +0100, Andrea Arcangeli wrote: > > CREATE INDEX indexname ON tablename ( position(' PREEMPT ' in kernel_version) ); > > The index only helps the above query with = 0 and not the one with != 0, > but it seems not needed in practice. Hrm. If you need indexing then, you'll probably have to do 2 indexes with a WHERE clause... CREATE INDEX ... WHERE position(...) = 0; CREATE INDEX ... WHERE position(...) != 0; I suspect this is because of a lack of stats for functional indexes. -- 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