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 562F5534A9 for ; Sun, 10 Apr 2005 22:41:36 -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 63873-10 for ; Mon, 11 Apr 2005 01:41:35 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 2DD485349C for ; Sun, 10 Apr 2005 22:41:34 -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 7218288; Sun, 10 Apr 2005 18:43:34 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: KeithW@narrowpathinc.com Subject: Re: 4 way JOIN using aliases Date: Sun, 10 Apr 2005 18:41:05 -0700 User-Agent: KMail/1.6.2 Cc: "PostgreSQL Perform" References: <20050407140133.M89867@narrowpathinc.com> In-Reply-To: <20050407140133.M89867@narrowpathinc.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <200504101841.05234.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/196 X-Sequence-Number: 11593 Keith, > Thanks to all on the NOVICE list that gave me help I now have a query > running that returns the results I am after. :-) =A0Now of course I want = it > to run faster. =A0Currently it clocks in at ~160ms. =A0I have checked ove= r the > indexes and I belive that the tables are indexed properly. =A0The largest > table, tbl_item, only has 2000 rows. =A0Is it possible to reduce the time= of > this query further? =A0 Probably not, no. For a 7-way join including 2 LEFT JOINs on the=20 unrestricted contents of all tables, 160ms is pretty darned good. If thes= e=20 tables were large, you'd be looking at a much longer estimation time. The= =20 only real way to speed it up would be to find a way to eliminate the left=20 joins. Also, PostgreSQL 8.0 might optimize this query a little better. The only thing I can see to tweak is that the estimate on the number of row= s=20 in tbl_item is wrong; probably you need to ANALYZE tbl_item. But I doubt= =20 that will make a difference in execution time. =2D-=20 Josh Berkus Aglio Database Solutions San Francisco