Re: Two Permance Questions

From: CoL <col(at)mportal(dot)hu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Two Permance Questions
Date: 2002-09-20 18:42:50
Message-ID: amfpvt$20ot$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

The select without subselect of course is better, and faster.
Check your "explain analyze select ..." to se the performance, and to
check the index usage if any.

C.

CN LIOU wrote:
> 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,

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2002-09-20 18:56:02 Re: Monitoring a Query
Previous Message Jean-Luc Lachance 2002-09-20 18:22:37 Getting acces to MVCC version number