X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EFD168BA1DF for ; Fri, 18 Feb 2005 18:25:08 +0000 (GMT) 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 01985-07 for ; Fri, 18 Feb 2005 18:25:05 +0000 (GMT) Received: from hotmail.com (bay103-f7.bay103.hotmail.com [65.54.174.17]) by svr1.postgresql.org (Postfix) with ESMTP id B454F8BA04C for ; Fri, 18 Feb 2005 18:25:04 +0000 (GMT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 18 Feb 2005 10:25:02 -0800 Message-ID: Received: from 142.179.217.124 by by103fd.bay103.hotmail.msn.com with HTTP; Fri, 18 Feb 2005 18:24:41 GMT X-Originating-IP: [142.179.217.124] X-Originating-Email: [jbowen333@hotmail.com] X-Sender: jbowen333@hotmail.com In-Reply-To: <4214ED42.5040802@archonet.com> From: "T- Bone" To: dev@archonet.com Cc: pgsql-sql@postgresql.org Subject: Re: Comments on subquery performance Date: Fri, 18 Feb 2005 11:24:41 -0700 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 18 Feb 2005 18:25:02.0254 (UTC) FILETIME=[292F94E0:01C515E7] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.548 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FROM_ENDS_IN_NUMS, MSGID_FROM_MTA_HEADER X-Spam-Level: * X-Archive-Number: 200502/210 X-Sequence-Number: 20321 Hi Richard and group, Thanks for the alternative approach. The code is certainly cleaner and easier to follow, but I do have a couple outer joins for fields #2 and #3 that could contain null values that are not captured in your example. Also, I ran an 'explain query' and the performance differences were negligable. Any further thoughts or should I just stick with what I have and move on? Thanks in advance. Cheers, Jim >From: Richard Huxton >To: T- Bone >CC: pgsql-sql@postgresql.org >Subject: Re: [SQL] Comments on subquery performance >Date: Thu, 17 Feb 2005 19:15:14 +0000 > >T- Bone wrote: >>(second attempt in two days to post this message...I appologise if for >>some reason a duplicate appears) >> >>Hello all, >> >>I created a query that contains two subqueries and joins and would like >>some feedback on whether: >> 1) this approach is logical; and, >> 2) if this is an optimal approach (performance wise) to return the >>records I seek. > >Well you could just do: > >SELECT > l.*, c1.catname, c2.catname, c3.catname >FROM > tbl_listing l, > tbl_categories c1, > tbl_categories c2, > tbl_categories c3 >WHERE > l.catid1 = c1.catid > AND l.catid2 = c2.catid > AND l.catid3 = c3.catid > >-- > Richard Huxton > Archonet Ltd > >---------------------------(end of broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org _________________________________________________________________ Scan and help eliminate destructive viruses from your inbound and outbound e-mail and attachments. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSNŽ Premium right now and get the first two months FREE*.