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 6426D53AF2 for ; Sun, 8 May 2005 21:48:24 -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 91710-01 for ; Mon, 9 May 2005 00:48:15 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 206C953AEA for ; Sun, 8 May 2005 21:48:14 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7337704; Sun, 08 May 2005 17:50:17 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Dan Harris Subject: Re: Query tuning help Date: Sun, 8 May 2005 17:48:18 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> In-Reply-To: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200505081748.18362.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/88 X-Sequence-Number: 12252 Dan, > =A0=A0=A0=A0=A0=A0=A0=A0and ( =A0recordtext like '%RED%' or recordtext li= ke '%CORVETTE%' =A0) =A0 It is simply not possible to use B-tree indexes on these kind of text queri= es. =20 B-trees require you to start at the "left" side of the field, because B-tre= es=20 locate records via <> tests. "Anywhere in the field" text search requires = a=20 =46ull Text Index. > The reason for the redundant LIKE clause is that first, I only want > those "incidentid"s that contain the words 'RED' and 'CORVETTE'. =A0BUT, > those two words may exist across multiple records with the same > incidentid. =A0Then, I only want to actually work with the rows that > contain one of the words. =A0This query will repeat the same logic for > however many keywords are entered by the user. =A0I have investigated > text searching options and have not found them to be congruous with my > application. Sounds like you either need to restructure your application, restructure yo= ur=20 database (so that you're not doing "anywhere in field" searches), or buy 32= GB=20 of ram so that you can cache the whole table. =2D-=20 Josh Berkus Aglio Database Solutions San Francisco