pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: CN LIOU <cnliou@graffiti.net>
To: pgsql-sql@postgresql.org
Subject: Two Permance Questions
Date: Fri, 20 Sep 2002 10:07:11 +0800
Message-ID: <20020920020711.32693.qmail@graffiti.net> (raw)

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



view thread (2+ messages)  latest in thread

Message-ID: <20020920020711.32693.qmail@graffiti.net>
Permalink:  ../20020920020711.32693.qmail@graffiti.net/
Also on:    postgresql.org/message-id/20020920020711.32693.qmail@graffiti.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cnliou@graffiti.net
  Subject: Re: Two Permance Questions
  In-Reply-To: <20020920020711.32693.qmail@graffiti.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox