Two Permance Questions

From: "CN LIOU" <cnliou(at)graffiti(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Two Permance Questions
Date: 2002-09-20 02:07:11
Message-ID: 20020920020711.32693.qmail@graffiti.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-09-20 02:59:38 Re: Query Freeze
Previous Message Christopher Kings-Lynne 2002-09-20 02:04:07 Re: Table Copy.