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