Re: sequential joins

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: sequential joins
Дата
Msg-id 3663.1015026196@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: sequential joins  (Oleg Lebedev <olebedev@waterford.org>)
Список 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 по дате отправления:

Предыдущее
От: Oleg Lebedev
Дата:
Сообщение: Re: sequential joins
Следующее
От: Dalton Shane
Дата:
Сообщение: arrays in stored procedures