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 DFCA28B9FB2 for ; Thu, 17 Feb 2005 19:15:29 +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 13660-02 for ; Thu, 17 Feb 2005 19:15:27 +0000 (GMT) Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by svr1.postgresql.org (Postfix) with ESMTP id 7479B8B9E99 for ; Thu, 17 Feb 2005 19:15:27 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-30.mail.demon.net with esmtp (Exim 4.42) id 1D1r7W-0003bY-2b; Thu, 17 Feb 2005 19:15:27 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 1286B15A0F; Thu, 17 Feb 2005 19:15:25 +0000 (GMT) Message-ID: <4214ED42.5040802@archonet.com> Date: Thu, 17 Feb 2005 19:15:14 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: T- Bone Cc: pgsql-sql@postgresql.org Subject: Re: Comments on subquery performance References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.064 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200502/202 X-Sequence-Number: 20313 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