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 9562953C44 for ; Mon, 9 May 2005 01:14:31 -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 31244-09 for ; Mon, 9 May 2005 04:14:29 +0000 (GMT) Received: from mailhub1.une.edu.au (mailhub.une.edu.au [129.180.1.122]) by svr1.postgresql.org (Postfix) with ESMTP id 87FC553B33 for ; Mon, 9 May 2005 01:14:23 -0300 (ADT) Received: from icarus.une.edu.au (icarus.une.edu.au [129.180.47.120]) by mailhub1.une.edu.au (Postfix) with ESMTP id 7E92C7EA5; Mon, 9 May 2005 14:14:22 +1000 (EST) Received: from kgb ([129.180.47.225]) by icarus.une.edu.au (8.12.8/8.12.8) with SMTP id j494EMG7016022; Mon, 9 May 2005 14:14:22 +1000 Date: Mon, 09 May 2005 14:17:17 +1000 From: Klint Gore To: Dan Harris Cc: pgsql-performance@postgresql.org Subject: Re: Query tuning help In-Reply-To: <7fc67646a961f5ebef90def7aeb95fd0@drivefaster.net> References: <200505081906.47731.josh@agliodbs.com> <7fc67646a961f5ebef90def7aeb95fd0@drivefaster.net> Message-Id: <427EE44D37F.5629KG@129.180.47.120> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver 1.25.06 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/98 X-Sequence-Number: 12262 On Sun, 8 May 2005 20:31:38 -0600, Dan Harris wrote: > Duly noted. If this method can search across rows, I'm willing to > accept this overhead for the speed it would add. You could use intersect to search across rows. Using tsearch2 will look up the RED and CORVETTE using the index and intersect will pull out the commmon rows. > In the meantime, is there any way I can reach my goal without Tsearch2 > by just restructuring my query to narrow down the results by date > first, then seq scan for the 'likes'? select distinct em.incidentid, ea.recordtext as retdata, eg.long, eg.lat >from ea, em, eg, ( select ea.incidentid from ea, em where em.incidentid = ea.incidentid and em.entrydate >= '2005-1-1 00:00' and em.entrydate <= '2005-5-9 00:00' and recordtext like '%RED%' intersect select ea.incidentid from ea, em where em.incidentid = ea.incidentid and em.entrydate >= '2005-1-1 00:00' and em.entrydate <= '2005-5-9 00:00' and recordtext like '%CORVETTE%' ) as iid where em.incidentid = ea.incidentid and em.incidentid = eg.incidentid and em.entrydate >= '2005-1-1 00:00' and em.entrydate <= '2005-5-9 00:00' and ea.incidentid = iid.incidentid and ( recordtext like '%RED%' or recordtext like '%CORVETTE%' ) order by em.entrydate klint. +---------------------------------------+-----------------+ : Klint Gore : "Non rhyming : : EMail : kg@kgb.une.edu.au : slang - the : : Snail : A.B.R.I. : possibilities : : Mail University of New England : are useless" : : Armidale NSW 2351 Australia : L.J.J. : : Fax : +61 2 6772 5376 : : +---------------------------------------+-----------------+