Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7C6F44764DF for ; Thu, 19 Sep 2002 22:08:28 -0400 (EDT) Received: from ws2.hk5.outblaze.com (202-77-181-84.outblaze.com [202.77.181.84]) by postgresql.org (Postfix) with SMTP id 56A434764A8 for ; Thu, 19 Sep 2002 22:08:26 -0400 (EDT) Received: (qmail 32694 invoked by uid 1001); 20 Sep 2002 02:07:11 -0000 Message-ID: <20020920020711.32693.qmail@graffiti.net> Content-Type: text/plain; charset="iso-8859-15" Content-Disposition: inline Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Mailer: MIME-tools 4.104 (Entity 4.117) Received: from [202.181.219.129] by ws2.hk5.outblaze.com with http for cnliou@graffiti.net; Fri, 20 Sep 2002 10:07:11 +0800 From: "CN LIOU" To: pgsql-sql@postgresql.org Date: Fri, 20 Sep 2002 10:07:11 +0800 Subject: Two Permance Questions X-Originating-Ip: 202.181.219.129 X-Originating-Server: ws2.hk5.outblaze.com X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/233 X-Sequence-Number: 9510 Hi! Q1. Is subquery better or join? For subquery: SELECT t1.c1,(SELECT t2.c2 FROM t2 WHERE t2.c1 = t1.c1) FROM t1 I wonder it will loop n times if t1 returns n rows. If this is the case, is it better to use join like this: SELECT t1.c1,t2.c2 FROM t1,t2 WHERE t2.c1 = t1.c1 Q2. If the query is not optimize like this: SELECT t1.c1,t2.c2 FROM t1,t2,t1,t2,t2 WHERE t2.c1=t1.c1 AND t1.c1=t2.c1 AND t1.c1=t2.c1 and the size of this clause can soar up to several kbytes, then can this query cause performance problem? Regards, -- _______________________________________________ Get your free email from http://www.graffiti.net Powered by Outblaze