Re: Any was to prevent a join if no columns are selected from a view?

Поиск
Список
Период
Сортировка
От Royce Ausburn
Тема Re: Any was to prevent a join if no columns are selected from a view?
Дата
Msg-id B8D2F7FF-A510-462E-A9BE-F65F1F1BC454@inomial.com
обсуждение исходный текст
Ответ на Re: Any was to prevent a join if no columns are selected from a view?  (Royce Ausburn <royce.ml@inomial.com>)
Список pgsql-general


On 30/09/2011, at 8:57 AM, Jason Long wrote:

I thought I had read somewhere that Postges could ignore a join if it
was not necessary because there were no columns from the table or view
selected in the query.  Is this possible?

You might be thinking of this enhancement introduced in 9.0:


  • Remove unnecessary outer joins (Robert Haas)

    Outer joins where the inner side is unique and not referenced above the join are unnecessary and are therefore now removed. This will accelerate many automatically generated queries, such as those created by object-relational mappers (ORMs).


Ack! Hit send too early.

Note that enhancement addresses only the case where the inner join is unique (ie a primary key or covered by a unique constraint).  My understanding of this is that in this case the outer join won't affect the number of rows returned, so if it's not used it's not necessary.  Without the unique constraint, or if it's not an outer join it still needs to be included, even if you're not referencing the table in select / conditions because the join affects the number of rows…. HTH.. and I hope I understand this correctly

В списке pgsql-general по дате отправления:

Предыдущее
От: Royce Ausburn
Дата:
Сообщение: Re: Any was to prevent a join if no columns are selected from a view?
Следующее
От: "Tendulker, Shivanand G Prabhu (SSTL)"
Дата:
Сообщение: Deadlock of REINDEX and SELECT queries in PostgresSQL 7.4