X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id AE4D79FB25E for ; Sun, 13 Aug 2006 11:43:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 52527-05 for ; Sun, 13 Aug 2006 11:43:24 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id CA0049FB227 for ; Sun, 13 Aug 2006 11:43:24 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1GCHNM-0004PA-9n for pgsql-sql@postgresql.org; Sun, 13 Aug 2006 10:55:40 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 0F8F74172; Sun, 13 Aug 2006 10:43:13 -0400 (EDT) Date: Sun, 13 Aug 2006 10:43:13 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Breaking up a query Message-ID: <20060813144312.GA16534@phlogiston.dyndns.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.043 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: ** X-Archive-Number: 200608/93 X-Sequence-Number: 26051 On Thu, Aug 10, 2006 at 06:53:33PM -0400, Saad Anis wrote: > Hi Guys, > > A fellow at work has written the SQL below to retrieve some data from > multiple tables. Obviously it is inefficient and unnecessarily complex, and Why is that obvious? Why do you think that joining in your application is going to give better performance than joining in the database? This is what RDBMS _do_, for heaven's sake. (I agree that your plan shows it's taking a long time. But that's a different problem. We don't actually know what you want from your query.) A -- Andrew Sullivan | ajs@crankycanuck.ca I remember when computers were frustrating because they *did* exactly what you told them to. That actually seems sort of quaint now. --J.D. Baldwin