pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Oleg Lebedev <olebedev@waterford.org>
Cc: Postgres SQL Mailing List <pgsql-sql@postgresql.org>
Subject: Re: sequential joins
Date: Fri, 01 Mar 2002 18:43:16 -0500
Message-ID: <3663.1015026196@sss.pgh.pa.us> (raw)
In-Reply-To: <3C801303.8DF6A0D1@waterford.org>
References: <web-814403@davinci.ethosmedia.com>
	<3C801303.8DF6A0D1@waterford.org>

Oleg Lebedev <olebedev@waterford.org> writes:
> SELECT *
> FROM
> activity a
> LEFT OUTER JOIN
>         (SELECT     username AS artistname,
>                             objectid AS userid
>         FROM         user) u1
> ON a.artist = u1.userid;

This seems like the hard way compared to

SELECT a.*, u1.username AS artistname, u1.objectid AS userid
       ... more fields here ...
FROM
activity a
LEFT OUTER JOIN user u1 ON a.artist = u1.userid
... more JOINs here ...

I think that you will in fact end up with the same plan, but that's
only because the PG planner is smart enough to convert the first
into the second.  Might as well save the notational cruft to begin with.

			regards, tom lane



view thread (6+ messages)  latest in thread

Message-ID: <3663.1015026196@sss.pgh.pa.us>
Permalink:  ../3663.1015026196@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3663.1015026196@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, olebedev@waterford.org
  Subject: Re: sequential joins
  In-Reply-To: <3663.1015026196@sss.pgh.pa.us>

* 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