X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 1948430FCA3 for ; Wed, 25 Jun 2003 16:39:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 72386-05 for ; Wed, 25 Jun 2003 13:39:46 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 77DEF30FC8F for ; Wed, 25 Jun 2003 13:39:40 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h5PGdbQQ004032; Wed, 25 Jun 2003 12:39:37 -0400 (EDT) To: michael.mattox@verideon.com Cc: =?iso-8859-1?Q?SZUCS_G=E1bor?= , pgsql-performance@postgresql.org Subject: Re: How to optimize monstrous query, sorts instead of using index In-reply-to: References: Comments: In-reply-to "Michael Mattox" message dated "Wed, 25 Jun 2003 16:48:46 +0200" Date: Wed, 25 Jun 2003 12:39:37 -0400 Message-ID: <4031.1056559177@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200306/170 X-Sequence-Number: 2254 "Michael Mattox" writes: > It's much slower but I appreciate you taking the time to try. I'm pretty > new to SQL so I must admin this query is very confusing for me. I'm using > Java Data Objects (JDO, an O/R mapping framework) but the implementation I'm > using (Kodo) isn't smart enough to do all the joins efficiently, which is > why I had to rewrite this query by hand. It wasn't till I read that :-( that I noticed that you were doing nested left joins. Fooling with the join order may be your best route to a solution --- have you read http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=explicit-joins.html regards, tom lane