Re: sequential joins - Mailing list pgsql-sql

From Tom Lane
Subject Re: sequential joins
Date
Msg-id 3663.1015026196@sss.pgh.pa.us
Whole thread Raw
In response to Re: sequential joins  (Oleg Lebedev <olebedev@waterford.org>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Oleg Lebedev
Date:
Subject: Re: sequential joins
Next
From: Dalton Shane
Date:
Subject: arrays in stored procedures