X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C1B3AD1D8BB for ; Tue, 2 Dec 2003 17:17:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 54908-09 for ; Tue, 2 Dec 2003 13:16:54 -0400 (AST) Received: from bramble.mmrd.com (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 871EED1C96D for ; Tue, 2 Dec 2003 13:16:49 -0400 (AST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id hB2GPqcM003471; Tue, 2 Dec 2003 11:25:53 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id hB2HGLl13424; Tue, 2 Dec 2003 12:16:22 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id XT87Z43S; Tue, 2 Dec 2003 12:16:19 -0500 Subject: Re: A question on the query planner From: Robert Treat To: Jared Carr Cc: pgsql-performance@postgresql.org In-Reply-To: <3FCBB639.10409@89glass.com> References: <3FCBB639.10409@89glass.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 02 Dec 2003 12:16:21 -0500 Message-Id: <1070385381.24915.8650.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/26 X-Sequence-Number: 4886 On Mon, 2003-12-01 at 16:44, Jared Carr wrote: > I am currently working on optimizing some fairly time consuming queries > on a decently large > dataset. > > The Following is the query in question. > > SELECT z.lat, z.lon, z.city, z.state, q.date_time, c.make, c.model, c.year > FROM quotes AS q, zips AS z, cars AS c > WHERE > z.zip = q.zip AND > c.car_id = q.car_id AND > z.state != 'AA' AND > z.state != 'AE' AND > z.state != 'AP' AND > z.state = 'WA' > ORDER BY date_time; > This wont completely solve your problem, but z.state = 'WA' would seem to be mutually exclusive of the != AA|AE|AP. While it's not much, it is extra overhead there doesn't seem to be any need for... Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL